home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / me310.zip / UE310DOC.ZIP / EMACS.MSS < prev    next >
Text File  |  1989-03-19  |  157KB  |  3,798 lines

  1. @style(indent 8 chars, spacing 1 lines, BindingMargin .5 inches)
  2. @pagefooting()
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.         @big(MicroEMACS)
  16.  
  17.         Full Screen Text Editor
  18.         Reference Manual
  19.  
  20.         Version 3.10
  21.         March 19, 1989
  22.  
  23.         (C)opyright 1988, 1989 by Daniel M. Lawrence
  24.         Reference Manual (C)opyright 1988, 1989
  25.             by Brian Straight and Daniel M. Lawrence
  26.         All Rights Reserved
  27.  
  28.         @i(MicroEMACS 3.10 can be copied and distributed freely
  29.         for any non-commercial purposes. MicroEMACS 3.10 can
  30.         only be incorporated into commercial software with
  31.         the permission of the current author.)
  32. @newpage
  33. @newpage
  34. @flushleft(@big[Introduction])
  35.  
  36.     MicroEMACS is a tool for creating and changing documents,
  37. programs, and other text files.  It is both relatively easy for the
  38. novice to use, but also very powerful in the hands of an expert.
  39. MicroEMACS can be extensively customized for the needs of the
  40. individual user.
  41.  
  42.     MicroEMACS allows several files to be edited at the same time.
  43. The screen can be split into different windows, and text may be moved
  44. freely from one window to the next.  Depending on the type of file being
  45. edited, MicroEMACS can change how it behaves to make editing simple. 
  46. Editing standard text files, program files and word processing documents
  47. are all possible at the same time.
  48.  
  49.     There are extensive capabilities to make word processing and
  50. editing easier.  These include commands for string searching and
  51. replacing, paragraph reformatting and deleting, automatic word wrapping,
  52. word move and deletes, easy case controlling, and automatic word counts.
  53.  
  54.     For complex and repetitive editing tasks editing macroes can be
  55. written.  These macroes allow the user a great degree of flexibility in
  56. determining how MicroEMACS behaves.  Also, any and all the commands can
  57. be used by any keystroke by changing, or rebinding, what commands
  58. various keys invoke.
  59.  
  60.     Special features are also available to perform a diverse set of
  61. operations such as file encryption, automatic backup file generation,
  62. entabbing and detabbing lines, executing operating system commands and
  63. filtering of text through other programs (like SORT to allow sorting
  64. text).
  65.  
  66. @flushleft(@big[History])
  67.  
  68.     EMACS was originally a text editor written by Richard Stallman
  69. at MIT in the early 1970s for Digital Equipment computers. Various
  70. versions, rewrites and clones have made an appearance since.
  71.  
  72.     This version of MicroEMACS is derived from code written by Dave
  73. G. Conroy in 1985.  Later modifications were performed by Steve Wilhite
  74. and George Jones.  In December of 1985 Daniel Lawrence picked up the
  75. then current source (version 2.0) and made extensive modifications and
  76. additions to it over the course of the next three years.  Updates and
  77. support for the current version are still available.  Commercial
  78. support and usage licences are also available.    The current program
  79. author can be contacted by writing to:
  80.  
  81. @begin(verbatim)
  82.     USMAIL: Daniel Lawrence
  83.         617 New York St
  84.         Lafayette, IN 47901
  85.  
  86.     UUCP:    pur-ee!pur-phy!j.cc.purdue.edu!nwd
  87.     ARPA:    nwd@@j.cc.purdue.edu
  88.     FIDO:    Opus 201/10 The Programmer's Room (317) 742-5533
  89. @end(verbatim)
  90. @newpage
  91. @flushleft(@big[Credits])
  92.  
  93.     Many people have been involved in creating this software and we
  94. wish to credit some of them here.  Dave Conroy, of course, wrote the
  95. very first version of MicroEMACS, and it is a credit to his clean
  96. coding that so much work was able to be done to expand it.  John Gamble
  97. is responsible for writing the MAGIC mode search routines, and for
  98. maintaining all the search code.  Dana Hoggatt supplied the encryption
  99. routines for encrypt mode and continues to answer really hard questions
  100. about MSDOS and UNIX.  Jeff Lomicka wrote the appendix on DEC VMS and
  101. has supplied a lot of code to support VMS and the ATARI 1040ST
  102. versions. Curtis Smith wrote the original VMS code and help support the
  103. Commodore AMIGA.  Also Lance Jones has done a lot of work on the AMIGA
  104. code.  Professor Suresh Konda at Purdue University has put a lot of
  105. effort into writing complex macros and finding all the bugs in the
  106. macro language before anyone else does.
  107.  
  108.     As to people sending source code and text translations over
  109. computer networks like USENET and ARPA net, there are simply more than
  110. can be listed here.  [The comments in the edit history in the main.c
  111. file mention each and the piece they contributed]. All these people
  112. should be thanked for the hard work they have put into MicroEMACS.
  113.  
  114. @closing(Daniel M. Lawrence)
  115. @newpage
  116. @string(ChapterTitle="")
  117. @set(page = 0)
  118. @pageheading(odd, left "@title[Chapter]", right "MicroEMACS Reference Manual")
  119. @pageheading(even, left "MicroEMACS Reference Manual", right "@title[Chapter]")
  120. @pagefooting(odd, left="@value(page)")
  121. @pagefooting(even, right="@value(page)")
  122. @chapter(Basic Concepts)
  123.  
  124.     The current version of MicroEMACS is 3.10 (Third major
  125. re-write, tenth public release), and for the rest of this document, we
  126. shall simply refer to this version as "EMACS".    Any modifications for
  127. later versions will be in the file README on the MicroEMACS distribution
  128. disk.
  129.  
  130. @section(Keys and the Keyboard)
  131.  
  132.     Many times throughout this manual we will be talking about
  133. @index(special keys) commands and the keys on the keyboard needed to use
  134. them.  There are a number of "special" keys which can be used and are
  135. listed here:
  136.  
  137. @begin(description)
  138. <NL>@\NewLine which is also called RETURN or ENTER, this key is used to
  139. @index(newline) end different commands. 
  140.  
  141. ^@\The control key can be used before any alphabetic character and some
  142. symbols.  For example, ^C means to hold down the <CONTROL> key and type
  143. @index(control key) the C key at the same time. 
  144.  
  145. ^X@\The CONTROL-X key is used at the beginning of many different
  146. @index(control-x) commands. 
  147.  
  148. META or M-@\This is a special EMACS key used to begin many commands as
  149. @index(meta key) well.    This key is pressed and then released before
  150. typing the next character.  On most systems, this is the <ESC> key, but
  151. it can be changed.  (consult appendix E to learn what key is used for
  152. META on your computer).
  153. @end(description)
  154.  
  155. Whenever a command is described, the manual will list the actual
  156. keystrokes needed to execute it in @b(boldface) using the above
  157. conventions, and also the name of the command in @i(italics).
  158. @section(Getting Started)
  159.  
  160.     In order to use EMACS, you must call it up from your system or
  161. computer's command prompt.  On UNIX and MSDOS machines, just type
  162. "emacs" from the main command prompt and follow it with the <RETURN> or
  163. <ENTER> key (we will refer to this key as <NL> for "new-line" for the
  164. remainder of this manual).  On the Macintosh, the Amiga, the ATARI ST
  165. and other icon based operating systems, double click on the uEMACS icon.
  166. Shortly after this, a screen similar to the one below should appear.
  167.  
  168. @section(Parts and Pieces)
  169.  
  170.     The screen is divided into a number of areas or @b<windows>.  On
  171. some systems the top window contains a function list of unshifted and
  172. @index(windows) shifted function keys.    We will discuss these keys later. 
  173. @index(mode line) Below them is an EMACS @b<mode line> which, as we will
  174. see, informs you of the present mode of operation of the editor--for
  175. example "(WRAP)" if you set EMACS to wrap at the end of each line. 
  176. @index(text window) Under the mode line is the @b<text window> where text
  177. appears and is manipulated.  Since each window has its own mode line,
  178. below the text window is it's mode line.  The last line of the screen is
  179. the @b(command line) where EMACS takes commands and reports on what it
  180. is doing. 
  181.  
  182. @begin(verbatim)
  183. ===============================================================================
  184. f1 search-> f2 <-search |    MicroEMACS:  Text Editor
  185. f3 hunt->   f4 <-hunt    | 
  186. f5 fkeys    f6 help    |  Available function key Pages include:
  187. f7 nxt wind f8 pg[    ] |    WORD  BOX    EMACS  PASCAL  C
  188. f9 save     f10 exit    |  [use the f8 key to load Pages]
  189. ===============================================================================
  190.    MicroEMACS 3.10 ()     Function Keys
  191. ===============================================================================
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203. ===============================================================================
  204. ---- MicroEMACS 3.10 () -- Main ----------------------------------------------
  205. ===============================================================================
  206.         Fig 1:    EMACS screen on an IBM-PC
  207. @end(verbatim)
  208.  
  209. @section(Entering Text)
  210.  
  211. Entering text in EMACS is simple.  Type the following sentence fragment:
  212.  
  213. @quotation<Fang Rock lighthouse, center of a series of mysterious and>
  214.  
  215. @flushleft(The text is displayed at the top of the text window.  Now type:)
  216.  
  217. @quotation<terrifying events at the turn of the century>
  218.  
  219. Notice that some of your text has dissapeared off the left side of the
  220. screen.  Don't panic--your text is safe!!! You've just discovered that
  221. EMACS doesn't "wrap" text to the next line like most word processors
  222. unless you hit <NL>.  But since EMACS is used for both word processing,
  223. and text editing, it has a bit of a dual personality.  You can change
  224. @index(modes) the way it works by setting various @b(modes).  In this
  225. case, you need to set @b(WRAP) mode, using the @i(add-mode)
  226. @index(add-mode) command, by typing @b(^XM).  The command line at the
  227. base of the screen will prompt you for the mode you wish to add.  Type
  228. @b<wrap> followed by the <NL> key and any text you now enter will be
  229. wrapped.  However, the command doesn't wrap text already entered.  To
  230. get rid of the long line, press and hold down the <BACKSPACE> key until
  231. the line is gone.  Now type in the words you deleted, watch how EMACS
  232. goes down to the next line at the right time.  @i{(In some versions of
  233. EMACS, @b<WRAP> is a default mode in which case you don't have to worry
  234. about the instructions relating to adding this mode.)}
  235.  
  236. Now let's type a longer insert.  Hit <NL> a couple of times to tab
  237. down from the text you just entered.  Now type the following paragraphs. 
  238. Press <NL> twice to indicate a paragraph break. 
  239.  
  240. @quotation<Fang Rock lighthouse, center of a series of mysterious and
  241. terrifying events at the turn of the century, is built on a rocky island
  242. a few miles of the Channel coast.  So small is the island that wherever
  243. you stand its rocks are wet with sea spray. 
  244.  
  245. The lighthouse tower is in the center of the island.  A steep flight of
  246. steps leads to the heavy door in its base.  Winding stairs lead up to
  247. the crew room.>
  248.  
  249. @section<Basic cursor movement>
  250.  
  251. Now let's practice moving around in this text.    To move the cursor back
  252. to the word "Winding," enter @b<M-B> @i(previous-word)
  253. @index(previous-word).    This command moves the cursor backwards by one
  254. word at a time.  Note you have to press the key combination every time
  255. the cursor steps back by one word.  Continuously pressing META and
  256. toggling B produces an error message.  To move forward to the word
  257. "stairs" enter @b<M-F> @i(next-word)@index(next-word), which moves the
  258. cursor forward by one word at a time. 
  259.  
  260. Notice that EMACS commands are usually mnemonic--F for forward, B for
  261. backward, for example.
  262.  
  263. To move the cursor up one line, enter @b<^P> @i(previous-line)
  264. @index(previous-line), down one line @b<^N> @i(next-line)
  265. @index(next-line).  Practice this movement by moving the cursor to the
  266. word "terrifying" in the second line. 
  267.  
  268. The cursor may also be moved forward or backward in smaller increments. 
  269. To move forward by one character, enter @b<^F> @i(forward-character)
  270. @index(forward-character), to move backward, @b<^B>
  271. @i(backward-character) @index(backward-character).  EMACS also allows
  272. you to specify a number which is normally used to tell a command to
  273. execute many times.  To repeat most commands, press META and then the
  274. number before you enter the command.  Thus, the command META 5 ^F
  275. (@b<M-5^F>) will move the cursor forward by five characters.  Try moving
  276. around in the text by using these commands.  For extra practice, see how
  277. close you can come to the word "small" in the first paragraph by giving
  278. an argument to the commands listed here. 
  279.  
  280. Two other simple cursor commands that are useful to help us move around
  281. in the text are @b<M-N> @i(next-paragraph) @index(next-paragraph) which
  282. moves the cursor to the second paragraph, and @b<M-P>
  283. @i(previous-paragraph) @index(previous-paragraph) which moves it back
  284. to the previous paragraph.  The cursor may also be moved rapidly from
  285. one end of the line to the other.  Move the cursor to the word "few" in
  286. the second line.  Press @b<^A> @i(beginning-of-line)
  287. @index(beginning-of-line).  Notice the cursor moves to the word
  288. "events" at the beginning of the line.    Pressing @b<^E> @i(end-of-line)
  289. @index(end-of-line) moves the cursor to the end of the line. 
  290.  
  291. Finally, the cursor may be moved from any point in the file to the end
  292. or beginning of the file.  Entering @b{M->} @i(end-of-file)
  293. @index(end-of-file) moves the cursor to the end of the buffer, @b{M-<}
  294. @i(beginning-of-file) @index(beginning-of-file) to the first character
  295. of the file. 
  296.  
  297. @i(On the IBM-PC, the ATARI ST and many other machines, the cursor keys
  298. @index(cursor keys) can also be used to move the cursor.)
  299.  
  300. Practice moving the cursor in the text until you are comfortable with
  301. the commands we've explored in this chapter.
  302.  
  303. @section(Saving your text)
  304.  
  305. When you've finished practicing cursor movement, save your file.  Your
  306. @index(buffer) file currently resides in a @b<BUFFER>.    The buffer is a
  307. temporary storage area for your text, and is lost when the computer is
  308. turned off.  You can save the buffer to a file by entering @b<^X^S>
  309. @i(save-file) @index(save-file).  Notice that EMACS informs you that
  310. your file has no name and will not let you save it.
  311.  
  312. To save your buffer to a file with a different name than it's current
  313. one (which is empty), press @b<^X^W> @i(write-file) @index(write-file). 
  314. EMACS will prompt you for the filename you wish to write.  Enter the
  315. name @b<fang.txt> and press return.  On a micro, the drive light will
  316. come on, and EMACS will inform you it is writing the file.  When it
  317. finishes, it will inform you of the number of lines it has written to
  318. the disk. 
  319.  
  320. Congratulations!! You've just saved your first EMACS file!
  321. @newpage
  322. @heading(Chapter @value(chapter) Summary)
  323.  
  324.     In chapter @value(chapter), you learned how to enter text, how
  325. to use wrap mode, how to move the cursor, and to save a buffer.  The
  326. following is a table of the commands covered in this chapter and their
  327. corresponding key bindings:
  328.  
  329. @begin{verbatim}
  330. @u(Key Binding        Keystroke    Effect)
  331.  
  332. abort-command        @b<^G>        aborts current command
  333.  
  334. add-mode        @b<^XM>     allows addition of EMACS
  335.                     mode such as @b(WRAP)
  336.  
  337. backward-character    @b<^B>        moves cursor left one character
  338.  
  339. beginning-of-file    @b{M-<}     moves cursor to beginning of file
  340.  
  341. beginning-of-line    @b<^A>        moves cursor to beginning of line
  342.  
  343. end-of-file        @b{M->}     moves cursor to end of file
  344.  
  345. end-of-line        @b<^E>        moves cursor to end of line
  346.  
  347. forward-character    @b<^F>        moves cursor right one character
  348.  
  349. next-line        @b<^N>        moves cursor to next line
  350.  
  351. next-paragraph        @b<M-N>     moves cursor to next paragraph
  352.  
  353. next-word        @b<M-F>     moves cursor forward one word
  354.  
  355. previous-line        @b<^P>        moves cursor backward by one line
  356.  
  357. previous-paragraph    @b<M-P>     moves cursor to previous paragraph
  358.  
  359. previous-word        @b<M-B>     moves cursor backward by one word
  360.  
  361. save-file        @b<^X^S>    saves current buffer to a file
  362.  
  363. write-file        @b<^X^W>    save current buffer under a new name
  364. @end(verbatim)
  365. @newpage
  366. @chapter(Basic Editing--Simple Insertions and Deletions)
  367.  
  368. @section<A Word About Windows, Buffers, Screens, and Modes>
  369.  
  370. In the first chapter, you learned how to create and save a file in
  371. EMACS.    Let's do some more editing on this file.  Call up emacs by
  372. typing in the following command.
  373.  
  374. @b<emacs fang.txt>
  375.  
  376. @i(On icon oriented systems, double click on the uEMACS icon, usually a
  377. file dialog box of some sort will appear.  Choose @b(FANG.TXT) from the
  378. appropriate folder.)
  379.  
  380. Shortly after you invoke EMACS, the text should appear on the screen
  381. ready for you to edit.    The text you are looking at currently resides in
  382. a @b<buffer>.  A buffer is a temporary area of computer memory which is
  383. @index(buffer) the primary unit internal to EMACS -- this is the place
  384. where EMACS goes to work.  The mode line at the bottom of the screen
  385. lists the buffer name, @b<FANG.TXT> and the name of the file with which
  386. this buffer is associated, @b<FANG.TXT>
  387.  
  388. The computer talks to you through the use of its @b(screen).  This
  389. @index(screen) screen usually has an area of 24 lines each of 80
  390. characters across.  You can use EMACS to subdivide the screen into
  391. several separate work areas, or @b(windows), each of which can be
  392. @index(window) 'looking into' different files or sections of text.  Using
  393. windows, you can work on several related texts at one time, copying and
  394. moving blocks of text between windows with ease.  To keep track of what
  395. you are editing, each window is identified by a @b(mode line) on the
  396. @index(mode line) @index(buffer) last line of the window which lists the
  397. name of the @b(buffer) which it is looking into, the file from which the
  398. text was read, and how the text is being edited. 
  399.  
  400. An EMACS @b<mode> tells EMACS how to deal with user input.  As we have
  401. already seen, the mode 'WRAP' controls how EMACS deals with long lines
  402. (lines with over 79 characters) while the user is typing them in.  The
  403. 'VIEW' mode, allows you to read a file without modifying it.  Modes are
  404. associated with buffers and not with files; hence, a mode needs to be
  405. explicitly set or removed every time you edit a file.  A new file read
  406. into a buffer with a previously specified mode will be edited under this
  407. mode.  If you use specific modes frequently, EMACS allows you to set
  408. the modes which are used by all new buffers, called @b<global> modes. 
  409.  
  410. @section<Insertions>
  411.  
  412. Your previously-saved text should look like this:
  413.  
  414. @quotation<Fang Rock lighthouse, center of a series of mysterious and
  415. terrifying events at the turn of the century, is built on a rocky island
  416. a few miles of the Channel coast.  So small is the island that wherever
  417. you stand its rocks are wet with sea spray. 
  418.  
  419. The lighthouse tower is in the center of the island.  A steep flight of
  420. steps leads to the heavy door in its base.  Winding stairs lead up to
  421. the crew room.>
  422.  
  423. Let's assume you want to add a sentence in the second paragraph after
  424. the word "base."  Move the cursor until it is on the "W" of "Winding".
  425. Now type the following:
  426.  
  427. @quotation<This gives entry to the lower floor where the big steam
  428. generator throbs steadily away, providing power for the electric
  429. lantern.>
  430.  
  431. If the line fails to wrap and you end up with a '$' sign in the right
  432. margin, just enter @b{M-Q} @i(fill-paragraph) @index(fill-paragraph) to
  433. reformat the paragraph.  This new command attempts to fill out a
  434. paragraph.  Long lines are divided up, and words are shuffled around to
  435. make the paragraph look nicer. 
  436.  
  437. Notice that all visible EMACS characters are self-inserting -- all you
  438. had to do was type the characters to insert and the existing text made
  439. space for it.  With a few exceptions discussed later, all non-printing
  440. characters (such as control or escape sequences) are commands.    To
  441. insert spaces, simply use the space bar.  Now move to the first line of
  442. the file and type @b{^O} @i(open-line) @index(open-line) (Oh, not zero). 
  443. You've just learned how to insert a blank line in your text. 
  444.  
  445. @section<Deletions>
  446.  
  447. EMACS offers a number of deletion options.  For example, move the cursor
  448. until it's under the period at the end of the insertion you just did. 
  449. Press the backspace key.  Notice the "n" on "lantern" disappeared.  The
  450. backspace implemented on EMACS is called a @b<destructive> backspace--it
  451. removes text immediately before the current cursor position from the
  452. buffer.  Now type @b<^H> @i(delete-previous-character)
  453. @index(delete-previous-character).  Notice that the cursor moves back
  454. and obliterates the "r"--either command will backspace the cursor. 
  455.  
  456. Type in the two letters you erased to restore your text and move the
  457. cursor to the beginning of the buffer @b{M->} @i(beginning-of-file)
  458. @index(beginning-of-file).  Move the cursor down one line to the
  459. beginning of the first paragraph. 
  460.  
  461. To delete the forward character, type @b{^D} @i(delete-next-character)
  462. @index(delete-next-character).    The "F" of "Fang" disappears.  Continue
  463. to type @b{^D} until the whole word is erased EMACS also permits the
  464. deletion of larger elements of text.  Move the cursor to the word
  465. "center" in the first line of text.  Pressing @b{M-<backspace>}
  466. @i(delete-previous-word) @index(delete-previous-word) kills the word
  467. immediately before the cursor.    @b{M-^H} has the same effect. 
  468.  
  469. Notice that the commands are very similar to the control commands you
  470. used to delete individual letters.  As a general rule in EMACS, control
  471. sequences affect small areas of text, META sequences larger areas.  The
  472. word forward of the cursor position can therefore be deleted by typing
  473. @b{M-D} @i(delete-next-word) @index(delete-next-word).    Now let's take
  474. out the remainder of the first line by typing @b{^K}
  475. @i(kill-to-end-of-line) @index(kill-to-end-of-line).  You now have a
  476. blank line at the top of your screen.  Typing @b{^K} again or @b{^X^O}
  477. @i(delete-blank-lines) @index(delete-blank-lines) deletes the blank line
  478. and flushes the second line to the top of the text.  Now exit EMACS by
  479. typing @b{^X^C} @i(exit-emacs) @index(exit-emacs).  Notice EMACS
  480. reminds you that you have not saved your buffer.  Ignore the warning and
  481. exit.  This way you can exit EMACS without saving any of the changes you
  482. just made. 
  483. @newpage
  484. @heading(Chapter @value(chapter) Summary)
  485.  
  486. In Chapter @value(chapter), you learned about the basic 'building
  487. blocks' of an EMACS text file--buffers, windows, and files. 
  488.  
  489. @begin{verbatim}
  490. @u(Key binding        Keystroke    Effect)
  491. delete-previous-character
  492.             @b{^H}        deletes character immediately before
  493.                     the current cursor position
  494.  
  495. delete-next-character    @b{^D}        deletes character immediately after     
  496.                     current cursor position
  497.  
  498. delete-previous-word    @b{M-^H}    deletes word immediately before
  499.                     current cursor position
  500.  
  501. delete-next-word    @b{M-D}     deletes word immediately after
  502.                     current cursor position
  503.  
  504. kill-to-end-of-line    @b<^K>        deletes from current cursor
  505.                     position to end of line
  506.  
  507. insert-space        @b<^C>        inserts a space to right of cursor
  508.  
  509. open-line        @b{^O}        inserts blank line
  510.  
  511. delete-blank-lines    @b{^X^O}    removes blank line
  512.  
  513. exit-emacs        @b{^X^C}    exits emacs
  514. @end(verbatim)
  515. @chapter(Using Regions)
  516.  
  517. @section(Defining and Deleting a Region)
  518.  
  519. At this point its time to familiarize ourselves with two more EMACS
  520. terms--the @b<point> and the @b<mark>.    The point is located directly
  521. @index(point) @index(mark) behind the current cursor position.    The mark
  522. (as we shall see shortly) is user defined.  These two elements together
  523. are called the current @b(region) and limit the @b<region> of text on
  524. which EMACS performs many of its editing functions. 
  525.  
  526. Let's begin by entering some new text.    Don't forget to add @b(wrap)
  527. mode if its not set on this buffer.  Start EMACS and open a file called
  528. @b{PUBLISH.TXT}.  Type in the following text:
  529.  
  530. @quotation{One of the largest growth areas in personal computing is
  531. electronic publishing.    There are packages available for practically
  532. every machine from elegantly simple programs for the humble Commodore 64
  533. to sophisticated professional packages for PC and Macintosh computers. 
  534.  
  535. Electronic publishing is as revolutionary in its way as the Gutenburg
  536. press.    Whereas the printing press allowed the mass production and
  537. distribution of the written word, electronic publishing puts the means
  538. of production in the hands of nearly every individual.    From the class
  539. magazine to the corporate report, electronic publishing is changing the
  540. way we produce and disseminate information. 
  541.  
  542. Personal publishing greatly increases the utility of practically every
  543. computer.  Thousands of people who joined the computer revolution of
  544. this decade only to hide their machines unused in closets have
  545. discovered a new use for them as dedicated publishing workstations.}
  546.  
  547. Now let's do some editing.  The last paragraph seems a little out of
  548. place.    To see what the document looks like without it we can cut it
  549. from the text by moving the cursor to the beginning of the paragraph. 
  550. Enter @b(M-<space>) @i(set-mark) @index(set-mark).  EMACS will respond
  551. with "[Mark set]".  Now move the cursor to the end of the paragraph. 
  552. You have just defined a region of text.  To remove this text from the
  553. screen, type @b<^W> @i(kill-region) @index(kill-region).  The paragraph
  554. disappears from the screen. 
  555.  
  556. On further consideration, however, perhaps the paragraph we cut wasn't
  557. so bad after all.  The problem may have been one of placement.    If we
  558. could tack it on to the end of the first paragraph it might work quite
  559. well to support and strengthen the argument.  Move the cursor to the end
  560. of the first paragraph and enter @b<^Y> @i(yank) @index(yank).    Your
  561. text should now look like this:
  562.  
  563. @quotation{One of the largest growth areas in personal computing is
  564. electronic publishing.    There are packages available for practically
  565. every machine from elegantly simple programs for the humble Commodore 64
  566. to sophisticated professional packages for PC and Macintosh computers. 
  567. Personal publishing greatly increases the utility of practically every
  568. computer.  Thousands of people who joined the computer revolution of
  569. this decade only to hide their machines unused in closets have
  570. discovered a new use for them as dedicated publishing workstations. 
  571.  
  572. Electronic publishing is as revolutionary in its way as the Gutenburg
  573. press.    Whereas the printing press allowed the mass production and
  574. distribution of the written word, electronic publishing puts the means
  575. of production in the hands of nearly every individual.    From the class
  576. magazine to the corporate report, electronic publishing is changing the
  577. way we produce and disseminate information.}
  578.  
  579. @section(Yanking a Region)
  580.  
  581. The text you cut initially didn't simply just disappear, it was cut into
  582. a buffer that retains the 'killed' text appropriately called the @b<kill
  583. buffer>.  @b<^Y> "yanks" the text back from this buffer into the current
  584. buffer. If you have a long line (indicated, remember, by the "$"
  585. sign), simply hit @b{M-Q} to reformat the paragraph. 
  586.  
  587. There are other uses to which the kill buffer can be put.  Using the
  588. @index(kill buffer) method we've already learned, define the last
  589. paragraph as a region.    Now type @b<M-W> @i(copy-region)
  590. @index(copy-region).  Nothing seems to have happened; the cursor stays
  591. blinking at the point.    But things have changed, even though you may not
  592. be able to see any alteration. 
  593.  
  594. To see what has happened to the contents of the kill buffer, move the
  595. cursor down a couple of lines and "yank" the contents of the kill buffer
  596. back with @b<^Y>.  Notice the last paragraph is now repeated.  The
  597. region you defined is "tacked on" to the end of your file because
  598. @b<M-W> @b<copies> a region to the kill buffer while leaving the
  599. original text in your working buffer.  Some caution is needed however,
  600. because the contents of the kill buffer are updated when you delete any
  601. regions, lines or words.  If you are moving large quantities of text,
  602. complete the operation before you do any more deletions or you could
  603. find that the text you want to move has been replaced by the most recent
  604. deletion.  Remember--a buffer is a temporary area of computer memory
  605. that is lost when the machine is powered down or switched off.    In order
  606. to make your changes permanent, they must be saved to a file before you
  607. leave EMACS.  Let's delete the section of text we just added and save
  608. the file to disk. 
  609.  
  610. @heading(Chapter @value(chapter) Summary)
  611.  
  612. In Chapter @value(chapter), you learned how to achieve longer insertions
  613. and deletions.    The EMACS terms @b<point> and @b<mark> were introduced
  614. and you learned how to manipulate text with the kill buffer. 
  615.  
  616. @begin{verbatim}
  617. @begin(group)
  618. @u(Key Binding    Keystroke    Effect)
  619.  
  620. set-mark    @b{M-<space>}    Marks the beginning of a region
  621.  
  622. delete-region    @b{^W}        Deletes region between point and mark and
  623.                 places it in KILL buffer
  624.  
  625. copy-region    @b{M-W}     Copies text between point and mark into
  626.                 KILL buffer
  627.  
  628. yank-text    @b{^Y}        Inserts a copy of the KILL buffer into
  629.                 current buffer at point
  630. @end(group)
  631. @end(verbatim)
  632. @chapter(Search and Replace)
  633.  
  634. @section<Forward Search>
  635.  
  636. Load EMACS and bring in the file you just saved.  Your file should look
  637. like the one below.
  638.  
  639. @quotation{One of the largest growth areas in personal computing is electronic
  640. publishing.  There are packages available for practically every machine
  641. from elegantly simple programs for the humble Commodore 64 to
  642. sophisticated professional packages for PC and Macintosh computers. 
  643. Personal publishing greatly increases the utility of practically every
  644. computer.  Thousands of people who joined the computer revolution of
  645. this decade only to hide their machines unused in closets have
  646. discovered a new use for them as dedicated publishing workstations. 
  647.  
  648. Electronic publishing is as revolutionary in its way as the Gutenburg
  649. press.    Whereas the printing press allowed the mass production and
  650. distribution of the written word, electronic publishing puts the means
  651. of production in the hands of nearly every individual.    From the class
  652. magazine to the corporate report, electronic publishing is changing the
  653. way we produce and disseminate information.}
  654.  
  655. Let's use EMACS to search for the word "revolutionary" in the second
  656. paragraph.  Because EMACS searches from the current cursor position
  657. toward the end of buffers, and we intend to search forward, move the
  658. cursor to the beginning of the text.  Enter @b<^S> @i(search-forward)
  659. @index(search-forward).  Note that the command line now reads
  660.  
  661. "Search [] <META>:" 
  662.  
  663. EMACS is prompting you to enter the @b<search string> -- the text you
  664. want to find.  Enter the word @b<revolutionary> and hit the @b<META>
  665. key.  The cursor moves to the end of the word "revolutionary."
  666.  
  667. Notice that you must enter the <META> key to start the search.    If you
  668. @index(<NL>) simply press <NL> the command line responds with "<NL>". 
  669. Although this may seem infuriating to users who are used to pressing the
  670. return key to execute any command, EMACS' use of <META> to begin
  671. searches allows it to pinpoint text with great accuracy.  After every
  672. line wrap or carriage return, EMACS 'sees' a new line character (<NL>). 
  673. If you need to search for a word at the end of a line, you can specify
  674. this word uniquely in EMACS. 
  675.  
  676. In our sample text for example, the word "and" occurs a number of times,
  677. but only once at the end of a line.  To search for this particular
  678. occurrence of the word, move the cursor to the beginning of the buffer
  679. and type @b(^S).  Notice that EMACS stores the last specified
  680. @index(default string) search string as the @b<default> string.  If you
  681. press @b{<META>} now, EMACS will search for the default string, in this
  682. case, "revolutionary."
  683.  
  684. To change this string so we can search for our specified "and" simply
  685. enter the word @b{and} followed by @b{<NL>}.  The command
  686. line now shows:
  687.  
  688. "search [and<NL>]<META>:"
  689.  
  690. Press @b{<META>} and the cursor moves to "and" at the end of the second
  691. last line.
  692.  
  693. @section<Exact Searches>
  694.  
  695. If the mode EXACT is active in the current buffer, EMACS searches on a case
  696. sensitive basis.  Thus, for example you could search for @b{Publishing}
  697. as distinct from @b{publishing}. 
  698.  
  699.  
  700. @section<Backward Search>
  701.  
  702. Backward searching is very similar to forward searching except that it
  703. is implemented in the reverse direction.  To implement a reverse search,
  704. type @b{^R} @i(search-reverse) @index(search-reverse).    Because EMACS
  705. makes no distinction between forward and backward stored search strings,
  706. the last search item you entered appears as the default string.  Try
  707. searching back for any word that lies between the cursor and the
  708. beginning of the buffer.  Notice that when the item is found, the point
  709. moves to the beginning of the found string (i.e., the cursor appears
  710. under the first letter of the search item). 
  711.  
  712. Practice searching for other words in your text.
  713.  
  714. @section<Searching and Replacing>
  715.  
  716. Searching and replacing is a powerful and quick way of making changes to
  717. your text.  Our sample text is about electronic publishing, but the
  718. correct term is 'desktop' publishing.  To make the necessary changes we
  719. need to replace all occurrences of the word "electronic" with "desktop."
  720. First, move the cursor to the top of the current buffer with the @b(M-<)
  721. command.  Then type @b[M-R] @i(replace-string) @index(replace-string). 
  722. The command line responds:
  723.  
  724. "Replace []<META>:"
  725.  
  726. where the square brackets enclose the default string.  Type the word
  727. @b<electronic> and hit @b{<META>}.  The command line responds:
  728.  
  729. "with []<META>"
  730.  
  731. type @b{desktop<META>}.  EMACS replaces all instances of the original
  732. word with your revision.  Of course, you will have to capitalize the
  733. first letter of "desktop" where it occurs at the beginning of a
  734. sentence.
  735.  
  736. You have just completed an @b<unconditional replace>.  In this
  737. operation, EMACS replaces every instance of the found string with the
  738. replacement string. 
  739.      
  740. @section<Query-Replace>
  741.  
  742. You may also replace text on a case by case basis.  The @b{M-^R}
  743. @i(query-replace-string) @index(query-replace-string) command causes
  744. EMACS to pause at each instance of the found string. 
  745.  
  746. For example, assume we want to replace some instances of the word
  747. "desktop" with the word "personal." Go back to the beginning of the
  748. current buffer and enter the @b(M-^R) @i(query-replace)
  749. @index(query-replace) command.    The procedure is very similar to that
  750. which you followed in the unconditional search/replace option.    When the
  751. search begins however, you will notice that EMACS pauses at each
  752. instance of "publishing" and asks whether you wish to replace it with
  753. the replacement string.  You have a number of options available for
  754. response:
  755.  
  756. @begin(verbatim)
  757. @u(    Response    Effect)
  758.     Y(es)    Make the current replacement and skip to the next
  759.         occurrence of the search string
  760.  
  761.     N(o)    Do not make this replacement but continue
  762.  
  763.     !    Do the rest of the replacements with no more queries
  764.  
  765.     U(ndo)    Undo just the last replacement and query for it
  766.         again (This can only go back ONE time)
  767.  
  768.     ^G    Abort the replacement command (This action does not
  769.         undo previously-authorized replacements
  770.  
  771.     .    Same effect as ^G, but cursor returns to the point at
  772.         which the replacement command was given
  773.  
  774.     ?    This lists help for the query replacement command
  775. @end(verbatim)
  776.  
  777. Practice searching and searching and replacing until you feel
  778. comfortable with the commands and their effects.
  779. @begin(group)
  780. @heading(Chapter @value(chapter) Summary)
  781.  
  782. In this chapter, you learned how to search for specified strings of text
  783. in EMACS.  The chapter also dealt with searching for and replacing
  784. elements within a buffer. 
  785.  
  786. @begin(verbatim)
  787. @u(Key Binding        Keystroke             Effect)
  788.  
  789. search-forward        @b{^S}    Searches from point to end of buffer.
  790.                 Point is moved from current location to
  791.                 the end of the found string
  792.  
  793. search-backward     @b{^R}    Searches from point to beginning of buffer. 
  794.                 Point is moved from current location to
  795.                 beginning of found string
  796.  
  797. replace         @b{M-R} Replace ALL occurrences of search string with 
  798.                 specified (null) string from point to the
  799.                 end of the current buffer
  800.  
  801. query-replace           @b{M-^R} As above, but pause at each found string
  802.                 and query for action
  803. @end(verbatim)
  804. @end(group)
  805. @chapter(Windows)
  806.  
  807. @section<Creating Windows>@index{Windows, Creating}
  808.  
  809. We have already met windows in an earlier chapter.  In this chapter, we
  810. will explore one of EMACS' more powerful features -- text manipulation
  811. through multiple windowing.  Windows offer you a powerful and easy way
  812. to edit text.  By manipulating a number of windows and buffers on the
  813. screen simultaneously, you can perform complete edits and revisions on
  814. the computer screen while having your draft text or original data
  815. available for reference in another window. 
  816.  
  817. You will recall that windows are areas of buffer text that you can see
  818. @index(windows) on the screen.    Because EMACS can support several screen
  819. windows simultaneously you can use them to look into different places in
  820. the same buffer.  You can also use them to look at text in different
  821. buffers.  In effect, you can edit several files at the same time. 
  822.  
  823. Let's invoke EMACS and pull back our file on desktop publishing by
  824. typing
  825.  
  826. @quotation<emacs publish.txt>
  827.  
  828. When the text appears, type the @b{^X2} @i(split-current-window)
  829. @index{split-current-window} command.  The window splits into two
  830. windows.  The window where the cursor resides is called the @b<current>
  831. window -- in this case the bottom window.  Notice that each window has
  832. a text area and a mode line.  The @b(command line) @index{command line}
  833. is however, common to all windows on the screen. 
  834.  
  835. The two windows on your screen are virtually mirror images of each other
  836. because the new window is opened into the same buffer as the one you are
  837. in when you issue the @i{open-window command} @index{open-window}.  All
  838. commands issued to EMACS are executed on the current buffer in the
  839. current window. 
  840.  
  841. To move the cursor to the upper window (i.e., to make that window the
  842. current window, type @b{^XP} @i(previous-window) @index{previous-window}.  
  843. Notice the cursor
  844. moves to the upper or @b<previous> window.  Entering @b{^XO}
  845. @i(next-window) moves to the @b{next} window.  Practice moving between
  846. windows.  You will notice that you can also move into the Function Key
  847. menu by entering these commands. 
  848.  
  849. Now move to the upper window.  Let's open a new file.  On the EMACS disk
  850. is a tutorial file.  Let's call it into the upper window by typing:
  851.  
  852. @quotation<^X^F>
  853.  
  854. and press return.
  855.  
  856. Enter the filename @b<emacs.tut>.
  857.  
  858. In a short time, the tutorial file will appear in the window.  We now have
  859. two windows on the screen, each looking into different buffers.  We have
  860. just used the @b(^X^F) @i(find-file) @index{find-file}
  861. command to find a file and bring
  862. it into our current window.
  863.  
  864. You can scroll any window up and down with the cursor keys, or with the
  865. commands we've learned so far.    However, because the area of visible
  866. text in each window is relatively small, you can scroll the current
  867. window a line at a time.  
  868.  
  869. Type @b{^X^N} @i(move-window-down)@index{move-window-down}
  870.  
  871. The current window scrolls down by one line -- the top line of text
  872. scrolls out of view, and the bottom line moves towards the top of the
  873. screen.  You can imagine, if you like, the whole window slowly moving
  874. down to the end of the buffer in increments of one line.  The command
  875. @b{^X^P} @i(move-window-up)@index{move-window-up} 
  876. scrolls the window in the opposite
  877. direction. 
  878.  
  879. As we have seen, EMACS editing commands are executed in the current
  880. window, but the program does support a useful feature that allows you
  881. to scroll the @b<next> window.     @b<M-^Z> @i(scroll-next-up)
  882. @index{scroll-next-up} scrolls the next window up, @b{M-^V}
  883. @i(scroll-next-down)@index{scroll-next-down}  scrolls it downward. 
  884. From the tutorial window, practice scrolling the window with the
  885. desktop publishing text in it up and down. 
  886.  
  887. When you're finished, exit EMACS without saving any changes in your
  888. files. 
  889.  
  890.  
  891. Experiment with splitting the windows on your screen.  Open windows
  892. into different buffers and experiment with any other files you may
  893. have.  Try editing the text in each window, but don't forget to save
  894. any changes you want to keep -- you still have to save each buffer
  895. separately.
  896.  
  897. @section(Deleting Windows)@index{Windows, Deleting}
  898. Windows allow you to perform complex editing tasks with ease.  However,
  899. they become an inconvenience when your screen is cluttered with open
  900. windows you have finished using.  The simplest solution is to delete
  901. unneeded windows.  The command @b{^X0} @i{delete-window}
  902. will delete the window you are currently working in and move you to the
  903. next window.
  904.  
  905. If you have a number of windows open, you can delete all but the current
  906. window by entering @b{^X1} @i{delete-other-windows}.
  907.  
  908. @section(Resizing Windows)@index{Windows, Resizing} 
  909.  
  910. During complex editing tasks, you will probably find it convenient to
  911. have a number of windows on the screen simultaneously.    However this
  912. situation may present inconveniences because the more windows you have
  913. on the screen the smaller they are; in some cases, a window may show
  914. only a couple of lines of text.  To increase the flexibility and utility
  915. of the window environment, EMACS allows you to resize the window you are
  916. working in (called, as you will recall, the @b<current> window) to a
  917. convenient size for easier editing, and then shrink it when you no
  918. longer need it to be so large. 
  919.  
  920. Let's try an example.  Load in any EMACS text file and split the current
  921. window into two.  Now type @b{^X^(Shift-6)},
  922. @i{grow-window}@index{grow-window}.  Your current window should be
  923. the lower one on the screen.  Notice that it increases in size upwards
  924. by one line.  If you are in the upper window, it increases in size in a
  925. downward direction.  The command @b{^X^Z},
  926. @i{shrink-window}@index{shrink-window} correspondingly decreases window
  927. size by one line at a time. 
  928.  
  929. EMACS also allows you to resize a window more precisely by entering a
  930. numeric argument specifying the size of the window in lines.  To resize
  931. the window this way, press the META key and enter a numeric argument
  932. (remember to keep it smaller than the number of lines on your screen
  933. display) then press @b{^XW} @i{resize-window}@index{resize-window}. 
  934. The current window will be enlarged or shrunk to the number of lines
  935. specified in the numeric argument.  For example entering:
  936.  
  937. @quotation{@b[M-8 ^XW]}will resize the current window to 8 lines.
  938.  
  939. @section(Repositioning within a Window)
  940.  
  941. The cursor may be centered within a window by entering @b{M-! or M-^L}
  942. @i{redraw-display} @index{redraw-display}.  This command is especially
  943. useful in allowing you to quickly locate the cursor if you are moving
  944. frequently from window to window.  You can also use this command to move
  945. the line containing the cursor to any position within the current
  946. window.  This is done by using a numeric argument before the command.
  947. Type @b(M-<n> M-^L) where <n> is the number of the line within the
  948. window that you wish the current line to be displayed.
  949.  
  950. The @b{^L} @i{Refresh-screen} @index{refresh-screen} command is useful
  951. for 'cleaning up' a 'messy' screen that can result of using EMACS on a
  952. mainframe system and being interrupted by a system message. 
  953. @newpage
  954. @u<Chapter @value(chapter) summary>
  955.  
  956. In Chapter @value(chapter) you learned how to manipulate windows and the
  957. editing flexibility they offer. 
  958.  
  959. @begin(verbatim)
  960. @u(Key Binding    Keystroke    Effect)
  961.  
  962. open-window    @b{^X2}     Splits current window into two windows if
  963.                 space available
  964.  
  965. close-windows    @b{^X1}     Closes all windows except current window
  966.  
  967. next-window    @b{^XO}[oh]    Moves point into next (i.e. downward) window
  968.  
  969. previous-window @b{^XP}     Moves point to previous (i.e. upward) window
  970.  
  971. move-window-down @b{^X^N}    Scrolls current window down one line
  972.  
  973. move-window-up    @b{^X^P}    Scrolls current window up one line
  974.  
  975. redraw-display    @b{M !} or    Window is moved so line with point
  976.         @b{M ^L}    (with cursor) is at center of window
  977.  
  978. grow-window    @b{M-X ^}    Current window is enlarged by one
  979.                 line and nearest window is shrunk by 
  980.                 one line
  981.  
  982. shrink-window    @b{^X^Z}    Current window is shrunk by one line
  983.                 and nearest window is enlarged by one line
  984.  
  985. clear-and-redraw @b{^L}     Screen is blanked and redrawn.    Keeps
  986.                 screen updates in sync with your commands
  987.  
  988. scroll-next-up    @b{M-^Z}    Scrolls next window up by one line
  989.  
  990. scroll-next-down @b{M-^V}    Scrolls next window down by one line
  991.  
  992. delete-window    @b{^X0}     Deletes current window
  993.  
  994. delete-other-windows @b{^X1}    Deletes all but current window
  995.  
  996. resize-window    @b{^X^W}    Resizes window to a given numeric argument
  997. @end(verbatim)
  998. @chapter(Using a Mouse)
  999.  
  1000.     On computers equipped with a mouse@index(mouse), the mouse can
  1001. usually be used to make editing easier.  If your computer has a mouse,
  1002. let's try using it.  Start MicroEMACS by typing:
  1003.  
  1004.     emacs publish.txt
  1005.  
  1006.     This brings EMACS up and allows it to edit the file from the
  1007. last chapter.  If the function key window is visible on the screen,
  1008. press the F5 key to cause it to disappear.  Now use the @b(^X2)
  1009. @i(split-current-window) command to split the screen into two windows. 
  1010. Next use the @b(^X^F) @i(find-file) command to read in the @b(fang.txt)
  1011. file.  Now your screen should have two windows looking into two
  1012. different files.
  1013.  
  1014.     Grab the mouse and move it around.  On the screen an arrow, or
  1015. block of color appears.  This is called the mouse cursor @index(mouse
  1016. cursor) and can be positioned on any character on the screen.  On some
  1017. computers, positioning the mouse cursor in the extreme upper right or
  1018. left corner may bring down menus which allow you to access that
  1019. computers utilities, sometimes called @b(Desk Accessories) @index(desk
  1020. accessories).
  1021.  
  1022. @section(Moving around with the mouse)
  1023.  
  1024.     Using the mouse button (or the left button if the mouse has more
  1025. than one), position the mouse over some character in the current window. 
  1026. Click the mouse button once.  The @b(point) will move to where the mouse
  1027. cursor is.  If you place the mouse cursor past the end of a line, the
  1028. point will move to the end of that line.
  1029.  
  1030.     Move the mouse cursor into the other window and click on one of
  1031. the characters there.  MicroEMACS will automatically make this window
  1032. the current window (notice that the mode line changes) and position the
  1033. point to the mouse cursor.  This makes it very easy to use the mouse to
  1034. switch to a different window quickly.
  1035.  
  1036. @section(Dragging around)
  1037.  
  1038.     Besides just using the mouse to move around on the screen, you
  1039. can use the same button to move text.  Move the mouse cursor to a
  1040. character in one of the windows, and click down... but don't let the
  1041. button up yet!    The point will move to where the mouse cursor is.  Now
  1042. move the mouse cursor up or down on the screen, and release the button.
  1043. The point will again move to where the mouse cursor is, but this time
  1044. it will bring the text under it along for the ride.  This is called
  1045. @b(dragging)@index(dragging), and is how you can make the text appear
  1046. just where you want it to.  If you try to drag text out of the current
  1047. window, EMACS will ignore your attempt and leave the point where you
  1048. first clicked down.  @index(vertical scrolling)
  1049.  
  1050.     Now, click down on a word in one of the windows, and drag it
  1051. directly to the left.  Release the button and watch as the entire
  1052. window slides, or @b(scrolls) @index(horizontal scrolling) to the left. 
  1053. The missing text has not been deleted, it is simply not visible, off the
  1054. left hand side of the screen.  Notice the mode line has changed and now
  1055. looks like:
  1056.  
  1057. @flushleft(==== MicroEMACS 3.10 [<12] () == fang.txt == File: fang.txt =========)
  1058.  
  1059.     The [] delimits a new field which indicates that the screen is
  1060. now scrolled 12 characters from the left margin.
  1061.  
  1062.     Now grab the same text again, and drag it to the right, pulling
  1063. the rest of the text back into the current window.  The [<] field will
  1064. disappear, meaning that the window is no longer scrolled to the left. 
  1065. This feature is very useful for looking at wide charts and tables. 
  1066. Remember, MicroEMACS will only scroll the text in the current window
  1067. sideways if you drag it straight to the side, otherwise it will drag
  1068. the text vertically.
  1069.  
  1070.     Now, place the mouse cursor over a character on the upper mode
  1071. line, click down, move the mouse cursor up or down a few lines and let
  1072. go of the button.  The mode line moves to where you dragged it, 
  1073. changing the size of the windows above and below it.  If you try to
  1074. make a window with less than one line, EMACS will not let you.    Dragging
  1075. the mode lines can make it very fast and easy for you to rearrange the
  1076. windows as you would like.
  1077.  
  1078.     If you have a number of different windows visible on the screen,
  1079. positioning the mouse over the mode line of one window and clicking the
  1080. right mouse button will cause that window to be deleted.
  1081.  
  1082. @section(Cut and Paste)
  1083.  
  1084.     If your mouse has two buttons, then you can use the right
  1085. button to do some other things as well.  Earlier, we learned how to
  1086. define a @b(region)@index(region) by using the @b(M-<space>)
  1087. @i(set-mark) command.  Now, position the mouse over at the beginning of
  1088. a region you would like to copy.  Next click and hold down the right
  1089. mouse button.  Notice that the point jumps to the mouse cursor and
  1090. EMACS reports "[Mark Set]".  Holding the button down move the mouse to
  1091. the  end of the text you wish to copy and release the mouse button. 
  1092. Emacs reports "[Region Copied]" to let you know it has copied the
  1093. region into the KILL buffer. If you now click the right mouse button,
  1094. without moving the mouse, the region you defined would be deleted or
  1095. @b(cut)@index(cut) from the current buffer.
  1096.  
  1097.     If you move the mouse again, and click the right mouse button
  1098. down and up without moving the mouse, the text in the KILL buffer gets
  1099. inserted, or pasted@index(paste) into the current buffer at the point. 
  1100.  
  1101. @newpage
  1102. @heading(Chapter @value(chapter) Summary)
  1103.  
  1104. In Chapter @value(chapter), you learned how to use the mouse to move the
  1105. point, switch windows, drag text, and resize windows.  You also learned
  1106. how to use the right mouse button in order to copy and delete regions
  1107. and yank them back at other places.
  1108.  
  1109. @begin{verbatim}
  1110. @begin(group)
  1111. @u(Action    Mouse Directions)
  1112.  
  1113. Move Cursor    position mouse cursor over desired location
  1114.         click down and up with left button
  1115.  
  1116. Drag Text    position mouse cursor over desired text
  1117.         click left button down
  1118.         move to new screen location for text
  1119.         release mouse button
  1120.  
  1121. Resize Windows    position mouse cursor over mode line to move
  1122.         click left button down
  1123.         move to new location for mode line
  1124.         release mouse button
  1125.  
  1126. Delete Window    position mouse cursor over mode line of window to delete
  1127.         click right mouse button
  1128.  
  1129. Resize Screen    position mouse cursor over last character on message line
  1130.         click left button down
  1131.         move to new lower right corner of screen
  1132.         release mouse button
  1133.  
  1134. Copy Region    position mouse at beginning of region
  1135.         click right button down
  1136.         move to end of region
  1137.         release mouse button
  1138.  
  1139. Cut Region    position mouse at beginning of region
  1140.         click right button down
  1141.         move to end of region
  1142.         release mouse button
  1143.         click right button down and up
  1144.  
  1145. Paste region    Position mouse at place to paste
  1146.         click right button down and up
  1147. @end(group)
  1148. @end(verbatim)
  1149. @chapter(Buffers)
  1150.  
  1151. @index(buffer)We have already learned a number of things about buffers.
  1152. As you will recall, they are the major internal entities in EMACS --
  1153. the place where editing commands are executed.    They are characterized
  1154. by their @b<names>, their @b<modes>, and by the file with which they
  1155. are associated.  Each buffer also "remembers" its @b(mark) and
  1156. @b(point).  This convenient feature allows you to go to other buffers
  1157. and return to the original location in the "current" buffer. 
  1158.  
  1159. Advanced users of EMACS frequently have a number of buffers in the
  1160. computer's memory simultaneously.  In the last chapter, for example, you
  1161. opened at least two buffers -- one into the text you were editing, and
  1162. the other into the EMACS on-line tutorial.  If you deal with complex
  1163. text files -- say, sectioned chapters of a book, you may have five or
  1164. six buffers in the computer's memory.  You could select different
  1165. buffers by simply calling up the file with @b{^X^F} @i(find-file)
  1166. @index(find-file), and let EMACS open or reopen the buffer.  However,
  1167. EMACS offers fast and sophisticated buffering techniques that you will
  1168. find easy to master and much more convenient to use. 
  1169.  
  1170. Let's begin by opening three buffers.  You can open any three you
  1171. choose, for example call the following files into memory: @b(fang.txt),
  1172. @b(publish.txt), and @b(emacs.tut) in the order listed here.  When
  1173. you've finished this process, you'll be looking at a screen showing the
  1174. EMACS tutorial.  Let's assume that you want to move to the fang.txt
  1175. buffer.  Enter:
  1176.  
  1177. @b{^XX} @i(next-buffer) @index(next-buffer)
  1178.  
  1179. This command moves you to the @u<next> buffer.    Because EMACS cycles
  1180. through the buffer list, which is alphabetized, you will now be in the
  1181. @b(fang.txt) buffer. Using @b(^XX) again places you in the
  1182. @b(publish.txt) buffer. @i(If you are on a machine that supports
  1183. function keys, using @b[^XX] again places you in the @b(Function Keys)
  1184. buffer). Using @b(^XX) one last time cycles you back to the beginning
  1185. of the list.
  1186.  
  1187. If you have a large number of buffers to deal with, this cycling process
  1188. may be slow and inconvenient.  The command @b{^XB} @i(select-buffer)
  1189. @index(select-buffer) allows you to specify the buffer you wish to be
  1190. switched to.  When the command is entered, EMACS prompts, "Use buffer:". 
  1191. Simply enter the buffer name (NOT the file name), and that buffer will
  1192. then become the current buffer.  If you type in part of the file name
  1193. and press the space bar, EMACS will attempt to complete the name from
  1194. the list of current buffers.  If it succeeds, it will print the rest of
  1195. the name and you can hit <NL> to switch to that buffer.  If EMACS beeps
  1196. the bell, there is no such buffer, and you may continue editing the name
  1197. on the command line.
  1198.  
  1199. Multiple buffer manipulation and editing is a complex activity, and you
  1200. will probably find it very inconvenient to re-save each buffer as you
  1201. modify it.  The command @b{^X^B} @i(list-buffers) @index(list-buffers)
  1202. creates a new window that gives details about all the buffers currently
  1203. known to EMACS.  Buffers that have been modified are identified by the
  1204. "buffer changed" indicator (an asterisk in the second column).    You can
  1205. thus quickly and easily identify buffers that need to be saved to files
  1206. before you exit EMACS.    The buffer window also provides other
  1207. information -- buffer specific modes, buffer size, and buffer name are
  1208. also listed.  To close this window, simply type the close-windows
  1209. command, @b{^X1}. 
  1210.  
  1211. To delete any buffer, type @b{^XK} @i(delete-buffer)
  1212. @index(delete-buffer).    EMACS prompts you "Kill buffer:".  Enter the
  1213. buffer name you want to delete.  As this is destructive command, EMACS
  1214. will ask for confirmation if the buffer was changed and not saved. 
  1215. Answer Y(es) or N(o).  As usual @b{^G} cancels the command. 
  1216.  
  1217. @newpage
  1218. @heading(Chapter @value(chapter) Summary)
  1219.  
  1220. In Chapter @value(chapter) you learned how to manipulate buffers. 
  1221.  
  1222. @begin{verbatim}
  1223. @u(Key Binding        Keystroke               Effect)
  1224. next-buffer        @b(^X^X)    Switch to the next buffer in the
  1225.                     buffer list
  1226.  
  1227. select-buffer        @b(^XB)     Switch to a particular buffer
  1228.  
  1229. list-buffers        @b(^X^B)    List all buffers
  1230.  
  1231. delete-buffer        @b(^XK)     Delete a particular buffer if it
  1232.                     is off-screen
  1233. @end(verbatim)
  1234. @chapter(Modes)
  1235.  
  1236.     EMACS allows you to change the way it works in order to
  1237. customized it to the style of editing you are using.  It does this by
  1238. providing a number of different @b(modes) @index(modes).  These modes
  1239. can effect either a single buffer, or any new buffer that is created. 
  1240. To add a mode to the current buffer, type @b(^XM) @i(add-mode)
  1241. @index(add-mode).  EMACS will then prompt you for the name of a mode to
  1242. add.  When you type in a legal mode name, and type a <NL>, EMACS will
  1243. add the mode name to the list of current mode names in the mode line of
  1244. the current buffer. 
  1245.  
  1246.     To remove an existing mode, typing the @b(^X^M) @i(delete-mode)
  1247. @index(delete-mode) will cause EMACS to prompt you for the name of a
  1248. mode to delete from the current buffer.  This will remove that mode from
  1249. the mode list on the current mode line.
  1250.  
  1251.     Global modes are the modes which are inherited by any new
  1252. buffers which are created.  For example, if you wish to always do string
  1253. searching with character case being significant, you would want global
  1254. mode EXACT to be set so that any new files read in inherent the EXACT
  1255. mode.  Global modes are set with the @b(M-M) @i(add-global-mode)
  1256. @index(add-global-mode) command, and unset with the @b(M-^M)
  1257. @i(delete-global-mode) @index(delete-global-mode) command.  Also, the
  1258. current global modes are displayed in the first line of a
  1259. @b(^X^B) @i(list-buffers) @index(list-buffers) command.
  1260.  
  1261.     On machines which are capable of displaying colors,
  1262. @index(color) the mode commands can also set the background and
  1263. foreground character colors.  Using @i(add-mode) or @i(delete-mode) with
  1264. a lowercase color will set the background color in the current window. 
  1265. An uppercase color will set the foreground color in the current window. 
  1266. Colors that EMACS knows about are: white, cyan, magenta, yellow, blue,
  1267. red, green, and black.    If the computer you are running on does not have
  1268. eight colors, EMACS will attempt to make some intelligent guess at what
  1269. color to use when you ask for one which is not there. 
  1270.  
  1271. @section(ASAVE mode)@index(ASAVE mode)
  1272.  
  1273.     Automatic Save mode tells EMACS to automatically write out the
  1274. current buffer to its associated file on a regular basis.  Normally this
  1275. will be every 256 characters typed into the file.  The environment
  1276. variable $ACOUNT counts down to the next auto-save, and $ASAVE is the
  1277. value used to reset $ACOUNT after a save occurs. 
  1278.  
  1279. @section(CMODE mode)@index(CMODE mode)
  1280.  
  1281.     CMODE is useful to C programmers.  When CMODE is active, EMACS
  1282. will try to assist the user in a number of ways.  This mode is set
  1283. automatically with files that have a .c or .h extension. 
  1284.  
  1285.     The <NL> key will normally attempt to return the user to the
  1286. next line at the same level of indentation as the last non blank line,
  1287. unless the current line ends with a open brace ({) in which case the
  1288. new line will be further indented by one tab position.
  1289.  
  1290.     A close brace (}) will search for the corresponding open brace
  1291. and line up with it.
  1292.  
  1293.     A pound sign (#) with only leading white space will delete all
  1294. the white space preceding itself. This will always bring preprocessor
  1295. directives flush to the left margin.
  1296.  
  1297.     Whenever any close fence is typed, IE )]>}, if the matching open
  1298. fence is on screen in the current window, the cursor will briefly flash
  1299. to it, and then back. This makes balancing expressions, and matching
  1300. blocks much easier.
  1301.  
  1302. @section(CRYPT mode)@index(CRYPT mode)
  1303.  
  1304.     When a buffer is in CRYPT mode, @index(encryption) it is
  1305. encrypted whenever it is written to a file, and decrypted when it is
  1306. read from the file.  The encryption key can be specified on the command
  1307. line with the -k switch, or with the @b(M-E) @i(set-encryption-key)
  1308. @index(set-encryption-key) command.  If you attempt to read or write a
  1309. buffer in crypt mode and now key has not been set, EMACS will execute
  1310. @i(set-encryption-key) automatically, prompting you for the needed key. 
  1311. Whenever EMACS prompts you for a key, it will not echo the key to your
  1312. screen as you type it (IE make SURE you get it right when you set it
  1313. originally).
  1314.  
  1315.     The encryption algorithm used changes all characters into normal
  1316. printing characters, thus the resulting file is suitable for sending via
  1317. electronic mail.  All version of MicroEMACS should be able decrypt the
  1318. resulting file regardless of what machine encrypted it.  Also available
  1319. with EMACS is the stand alone program, MicroCRYPT, which can en/decrypt
  1320. the files produced by CRYPT mode in EMACS.
  1321.  
  1322. @section(EXACT mode)@index(EXACT mode)
  1323.  
  1324.     All string searches and replacements will take upper/lower case
  1325. into account. Normally the case of a string during a search or replace
  1326. is not taken into account.
  1327.  
  1328. @section(MAGIC mode)@index(MAGIC mode)
  1329.  
  1330.      In the MAGIC mode certain characters gain special meanings when
  1331. used in a search pattern.  Collectively they are know as regular
  1332. expressions, and a limited number of them are supported in MicroEmacs. 
  1333. They grant greater flexibility when using the search command.  However,
  1334. they do not affect the incremental search command. 
  1335.  
  1336.      The symbols that have special meaning in MAGIC mode are
  1337. ^, $, ., &, *, [ (and ], used with it), and \.
  1338.  
  1339.      The characters ^ and $ fix the search pattern to the beginning and
  1340. end of line, respectively.  The ^ character must appear at the beginning
  1341. of the search string, and the $ must appear at the end, otherwise they
  1342. loose their meaning and are treated just like any other character.  For
  1343. example, in MAGIC mode, searching for the pattern "t$" would put the
  1344. cursor at the end of any line that ended with the letter 't'.  Note that
  1345. this is different than searching for "t<NL>", that is, 't' followed by a
  1346. newline character.  The character $ (and ^, for that matter) matches a
  1347. position, not a character, so the cursor remains at the end of the line. 
  1348. But a newline is a character that must be matched, just like any other
  1349. character, which means that the cursor is placed just after it - on the
  1350. beginning of the next line. 
  1351.  
  1352.      The character .  has a very simple meaning -- it matches any single
  1353. character, except the newline.    Thus a search for "bad.er" could match
  1354. "badger", "badder" (slang), or up to the 'r' of "bad error". 
  1355.  
  1356.      The character * is known as closure, and means that zero or more of
  1357. the preceding character will match.  If there is no character preceding,
  1358. * has no special meaning, and since it will not match with a newline, *
  1359. will have no special meaning if preceded by the beginning of line symbol
  1360. ^ or the literal newline character <NL>. 
  1361.  
  1362.      The notion of zero or more characters is important.  If, for
  1363. example, your cursor was on the line
  1364.  
  1365. @quotation(This line is missing two vowels.)
  1366.  
  1367. and a search was made for "a*", the cursor would not move, because it is
  1368. guaranteed to match no letter 'a' , which satisfies the search
  1369. conditions.  If you wanted to search for one or more of the letter 'a',
  1370. you would search for "aa*", which would match the letter a, then zero or
  1371. more of them. 
  1372.  
  1373.      The character [ indicates the beginning of a character class.  It
  1374. is similar to the 'any' character ., but you get to choose which
  1375. characters you want to match.  The character class is ended with the
  1376. character ].  So, while a search for "ba.e" will match "bane", "bade",
  1377. "bale", "bate", et cetera, you can limit it to matching "babe" and
  1378. "bake" by searching for "ba[bk]e".  Only one of the characters inside
  1379. the [ and ] will match a character.  If in fact you want to match any
  1380. character except those in the character class, you can put a ^ as the
  1381. first character.  It must be the first character of the class, or else
  1382. it has no special meaning.  So, a search for [^aeiou] will match any
  1383. character except a vowel, but a search for [aeiou^] will match any vowel
  1384. or a ^.
  1385.  
  1386. If you have a lot of characters in order that you want to put in the
  1387. character class, you may use a dash (-) as a range character.  So, [a-z]
  1388. will match any letter (or any lower case letter if EXACT mode is on),
  1389. and [0-9a-f] will match any digit or any letter 'a' through 'f', which
  1390. happen to be the characters for hexadecimal numbers.  If the dash is at
  1391. the beginning or end of a character class, it is taken to be just a
  1392. dash. 
  1393.  
  1394.      The character & (ampersand) is a replacement character, and
  1395. represents the characters which matched the search string.  When used in
  1396. the @b[M-R] @i(replace-string) @index(replace-string) or the @b[M-^R]
  1397. @i(query-replace-string) @index(query-replace-string) commands, the &
  1398. will be substituted for the search string. 
  1399.  
  1400.      The escape character \ is for those times when you want to be in
  1401. MAGIC mode, but also want to use a regular expression character
  1402. to be just a character.  It turns off the special meaning of the
  1403. character.  So a search for "it\." will search for a line with "it.",
  1404. and not "it" followed by any other character.  The escape character
  1405. will also let you put ^, -, or ] inside a character class with no
  1406. special side effects.
  1407.  
  1408. @section(OVER mode)@index(OVER mode)
  1409.  
  1410.     OVER mode stands for overwrite mode.  When in this mode, when
  1411. characters are typed, instead of simply inserting them into the file,
  1412. EMACS will attempt to overwrite an existing character past the point. 
  1413. This is very useful for adjusting tables and diagrams. 
  1414.  
  1415. @section(WRAP mode)@index(WRAP mode)
  1416.  
  1417.     Wrap mode is used when typing in continuous text.  Whenever the
  1418. cursor is past the currently set fill column @index(fill column) (72 by
  1419. default) and the user types a space or a <NL>, the last word of the line
  1420. is brought down to the beginning of the next line.  Using this, one just
  1421. types a continuous stream of words and EMACS automatically inserts <NL>s
  1422. at appropriate places.
  1423.  
  1424. @center(NOTE to programmers:)
  1425.  
  1426. @quotation{The EMACS variable $wraphook contains the name of the
  1427. function which executes when EMACS detects it is time to wrap. This is
  1428. set to the function @i(wrap-word) @index(wrap-word) by default, but can
  1429. be changed to activate different functions and macros at wrap time.}
  1430.  
  1431. @section(VIEW mode)@index(VIEW mode)
  1432.  
  1433.     VIEW mode disables all commands which can change the current
  1434. buffer.  EMACS will display an error message and ring the bell every
  1435. time you attempt to change a buffer in VIEW mode.
  1436. @newpage
  1437. @heading(Chapter @value(chapter) Summary)
  1438.  
  1439. In Chapter @value(chapter) you learned about modes and their effects.
  1440.  
  1441. @begin{verbatim}
  1442. @u(Key Binding        Keystroke               Effect)
  1443. add-mode        @b(^XM)     Add a mode to the current buffer
  1444.  
  1445. delete-mode        @b(^X^M)    Delete a mode from the current buffer
  1446.  
  1447. add-global-mode     @b(M-M)     Add a global mode to the
  1448.                     current buffer
  1449.  
  1450. delete-global-mode    @b(M-^M)    Delete a global mode from the
  1451.                     current buffer
  1452. @end(verbatim)
  1453. @chapter(Files)
  1454.  
  1455. A file is simply a collection of related data.    In EMACS we are dealing
  1456. with text files -- named collections of text residing on a disk (or some
  1457. other storage medium).    You will recall that the major entities EMACS
  1458. deals with are buffers.  Disk-based versions of files are only active in
  1459. EMACS when you are reading into or writing out of buffers.  As we have
  1460. already seen, buffers and physical files are linked by associated
  1461. file names.  For example, the buffer "ch7.txt" which is associated with
  1462. the physical disk file "ch7.txt." You will notice that the file is
  1463. usually specified by the drive name or (in the case of a hard drive) a
  1464. path.  Thus you can specify full file names in EMACS,
  1465.  
  1466. e.g. disk:\directories\filename.extension
  1467.  
  1468. If you do not specify a disk and directories, the default disk and the
  1469. current directory is used.
  1470.  
  1471. IMPORTANT -- If you do not explicitly save your buffer to a file, all your
  1472. edits will be lost when you leave EMACS (although EMACS will prompt you
  1473. when you are about to lose edits by exiting).  In addition, EMACS does
  1474. not protect your disk-based files from overwriting when it saves files. 
  1475. Thus when you instruct EMACS to save a file to disk, it will create a
  1476. file if the specified file doesn't exist, or it will overwrite the
  1477. previously saved version of the file thus replacing it.  Your old
  1478. version is gone forever. 
  1479.  
  1480. If you are at all unsure about your edits, or if (for any reason) you
  1481. wish to keep previous versions of a file, you can change the name of
  1482. the associated file with the command @b{^XN}
  1483. @i(change-file-name)@index(change-file-name).  When this file is saved
  1484. to disk, EMACS will create a new physical file under the new name.  The
  1485. earlier disk file will be preserved.
  1486.  
  1487. For example, let's load the file @b{fang.txt} into EMACS.  Now, type
  1488. @b{^XN}.  The EMACS command line prompts "Name:".  Enter a new name
  1489. for the file -- say @b(new.txt) and press <NL>.  The file will be
  1490. saved under the new filename, and your disk directory will show both
  1491. @b(fang.txt) and @b(new.txt).
  1492.  
  1493. An alternative method is to write the file directly to disk under a new
  1494. filename.  Let's pull our "publish.txt" file into EMACS.  To write this
  1495. file under another filename, type @b{^X^W}
  1496. @i(write-file)@index(writefile).  EMACS will prompt you "write file:". 
  1497. Enter an alternate filename -- @b{desktop.txt}.  Your file will be
  1498. saved as the physical file "desktop.txt".
  1499.  
  1500. Note that in the examples above, although you have changed the names of
  1501. the related files, the buffer names remain the same.  However, when you
  1502. pull the physical file back into EMACS, you will find that the buffer
  1503. name now relates to the filename.
  1504.  
  1505. For example -- You are working with a buffer "fang.txt" with the related
  1506. file "fang.txt".  You change the name of the file to "new.txt".  EMACS
  1507. now shows you working with the buffer "fang.txt" and the related file
  1508. "new.txt".  Now pull the file "new.txt" into EMACS.  Notice that the
  1509. buffer name has now changed to "new.txt". 
  1510.  
  1511. If for any reason a conflict of buffer names occurs,(if you have files
  1512. of the same name on different drives for example) EMACS will prompt
  1513. you "use buffer:".  Enter an alternative buffer name if you need to. 
  1514.  
  1515. For a list of file related commands (including some we`ve already
  1516. seen), see the summary page.
  1517. @newpage
  1518. @heading(Chapter @value(chapter) Summary)
  1519.  
  1520. In Chapter @value(chapter) you learned some of the more advanced
  1521. concepts of file naming and manipulation.  The relationship between
  1522. files and buffers was discussed in some detail. 
  1523.  
  1524. @begin(verbatim)
  1525. @u(Key Binding    Keystroke    Effect)
  1526.  
  1527. save-file    @b{^X^S}    Saves contents of current buffer with
  1528.                 associated filename on default disk/
  1529.                 directory (if not specified)
  1530.  
  1531. write-file    @b{^X^W}    Current buffer contents will be
  1532.                 saved under specified name 
  1533.  
  1534. change-file-name
  1535.         @b{^XN}     The associated filename is changed
  1536.                 (or associated if not previously
  1537.                 specified) as specified
  1538.  
  1539. find-file    @b{^X^F}    Reads specified file into buffer and 
  1540.                 switches you to that buffer, or switches
  1541.                 to buffer in which the file has previously
  1542.                 been read
  1543.  
  1544. read-file    @b{^X^R}    Reads file into buffer thus overwriting
  1545.                 buffer contents.  If file has already
  1546.                 been read into another buffer, you will
  1547.                 be switched to it
  1548.  
  1549. view-file    @b{^X^V}    The same as read-file except the buffer
  1550.                 is automatically put into VIEW mode thus 
  1551.                 preventing any changes from being made
  1552. @end{verbatim}
  1553. @chapter(Screen Formatting)
  1554.  
  1555. @section<Wrapping Text>
  1556.  
  1557. As we learned in the introduction, EMACS is not a word processor, but an
  1558. editor.  Some simple formatting options are available however, although
  1559. in most cases they will not affect the appearance of the finished text
  1560. @index(wrapping text) when it is run through the formatter.  We have
  1561. already encountered WRAP mode which wraps lines longer than a certain
  1562. length (default is 75 characters).  You will recall that WRAP is enabled
  1563. by entering @b{^XM} and responding to the command line prompt with
  1564. @b{wrap}. 
  1565.  
  1566. You can also set your own wrap margin with the command @b{^XF}
  1567. @i(set-fill-column) @index(set-fill-column).  Notice EMACS responds
  1568. "[Fill column is 1]." Now try typing some text.  You'll notice some very
  1569. strange things happening -- your text wraps at every word!! This effect
  1570. occurs because the set wrap margin command must be preceded by a
  1571. numeric argument or EMACS sets it to the first column.    Thus any text
  1572. you type that extends past the first column will wrap at the most
  1573. convenient line break. 
  1574.  
  1575. To reset the wrap column to 72 characters, press the @b{<META>} key and
  1576. enter 72.  EMACS will respond "Arg: 72".  Now press @b<^XF>.  EMACS
  1577. will respond "[Fill column is 72]".  Your text will again wrap at the
  1578. margin you've been using up to this point.
  1579.  
  1580. @section<Reformatting Paragraphs>
  1581.  
  1582. After an intensive editing session, you may find that you have
  1583. paragraphs containing lines of differing lengths.  Although this
  1584. disparity will not affect the formatted text, aesthetic and technical
  1585. concerns may make it desirable to have consistent paragraph blocks on
  1586. the screen.  If you are in WRAP mode, you can reformat a paragraph with
  1587. the command @b{M-Q} @i(fill-paragraph) @index(fill-paragraph).    This
  1588. command 'fills' the current paragraph reformatting it so all the lines
  1589. are filled and wrap logically.
  1590.  
  1591. @section<Changing Case>
  1592.  
  1593. There may be occasions when you find it necessary to change the case of
  1594. the text you've entered.  EMACS allows you to change the case of even
  1595. large amounts of text with ease.  Let's try and convert a few of the
  1596. office traditionalists to the joy of word processing.  Type in the
  1597. following text:
  1598.  
  1599. @quotation{Throw away your typewriter and learn to use a word processor. 
  1600. Word processing is relatively easy to learn and will increase your
  1601. productivity enormously.  Enter the Computer Age and find out just how
  1602. much fun it can be!!}
  1603.  
  1604. Let's give it a little more impact by capitalizing the first four words. 
  1605. The first step is to define the region of text just as you would if you
  1606. were doing an extensive deletion.  Set the mark at the beginning of the
  1607. paragraph with @b{M-<space>} @i(set-mark) and move the cursor to the
  1608. space beyond "typewriter." Now enter @b{^X^U} @i(case-region-upper). 
  1609. Your text should now look like this:
  1610.  
  1611. @quotation{THROW AWAY YOUR TYPEWRITER and learn to use a word processor. 
  1612. Word processing is relatively easy to learn and will increase your
  1613. productivity enormously.  Enter the Computer Age and find out just how
  1614. much fun it can be!!}
  1615.  
  1616. If you want to change the text back to lower case, type @b{^X^L}
  1617. @i(case-region-lower) @index(case-region-lower).  You can also
  1618. capitalize individual words.  To capitalize the word "fun", position the
  1619. cursor in front of the word and type @b{M-U} @i(case-word-upper)
  1620. @index(case-word-upper).  The word is now capitalized.    To change it
  1621. ck to lower case, move the cursor back to the beginning of the word
  1622. and type @b{M-L} @i(case-word-lower) @index(case-word-lower). 
  1623.  
  1624. You may also capitalize individual letters in EMACS.  The command
  1625. @b{M-C} @i(case-word-capitalize) @index(case-word-capitalize)
  1626. capitalizes the first letter after the point.  This command would
  1627. normally be issued with the cursor positioned in front of the first
  1628. letter of the word you wish to capitalize.  If you issue it in the
  1629. middle of a word, you can end up with some strAnge looking text. 
  1630.  
  1631. @section<Tabs>
  1632.  
  1633. Unless your formatter is instructed to take screen text literally (as
  1634. MicroSCRIBE does in the 'verbatim' environment for example), tabs in
  1635. EMACS generally affect screen formatting only. 
  1636.  
  1637. When EMACS is first started, it sets the default tab to every eighth
  1638. column.  As long as you stay with default, every time you press the tab
  1639. key a tab character, @b(^I) is inserted.  This character, like other
  1640. control characters, is invisible -- but it makes a subtle and
  1641. significant difference to your file and editing. 
  1642.  
  1643. For example, in default mode, press the tab key and then type the word
  1644. @b{Test}.  "Test" appears at the eighth column.  Move your cursor to the
  1645. beginning of the word and delete the backward character.  The word
  1646. doesn't move back just one character, but flushes to the left margin. 
  1647. The reason for this behavior is easily explained.  In tab default, EMACS
  1648. inserts a 'real' tab character when you press the tab key.  This
  1649. character is inserted at the default position, but NO SPACES are
  1650. inserted between the tab character and the margin (or previous tab
  1651. character).  As you will recall, EMACS only recognizes characters (such
  1652. as spaces or letters) and thus when the tab character is removed, the
  1653. text beyond the tab is flushed back to the margin or previous tab mark.
  1654.  
  1655. This situation changes if you alter the default configuration.    The
  1656. default value may be changed by entering a numeric argument before
  1657. pressing the tab key.  As we saw earlier, pressing the @b{META} key and
  1658. entering a number allows you to specify how EMACS performs a given
  1659. action.  In this case, let's specify an argument of 10 and hit the tab
  1660. key. 
  1661.  
  1662. Now hit the tab key again and type @b{Test}.  Notice the word now
  1663. appears at the tenth column.  Now move to the beginning of the word and
  1664. delete the backward character.    "Test" moves back by one character. 
  1665.  
  1666. EMACS behaves differently in these circumstances because the @b(^I)
  1667. @index(tab handling) @i(handle-tab) @index(handle-tab) function deals
  1668. with tabbing in two distinct ways.  In default conditions, or if the
  1669. numeric argument of zero is used, @i(handle-tab) inserts a true tab
  1670. character.  If, however, a non-zero numeric argument is specified,
  1671. @i(handle-tab) inserts the correct number of spaces needed to position
  1672. the cursor at the next specified tab position.    It does NOT insert the
  1673. single tab character and hence any editing functions should take account
  1674. of the number of spaces between tabbed columns.
  1675.  
  1676. The distance which a true tab character moves the cursor can be
  1677. modified by changing the value of the $hardtab environment variable. 
  1678. Initially set to 8, this will determine how far each tab stop is placed
  1679. from the previous one.    (Use the ^XA @i(set)@index(set) command to set
  1680. the value of an environment variable).
  1681.  
  1682. Many times you would like to take text which has been created using
  1683. the tab character and change it to use just spaces.  The command
  1684. @b(^X^D) @i(detab-region) @index(detab-region) changes any tabs 
  1685. in the currently selected region into the right number of spaces so
  1686. the text does not change.  This is very useful for times when the file
  1687. must be printed or transferred to a machine which does not understand
  1688. tabs. 
  1689.  
  1690. Also, the inverse command, @b(^X^E) @i(entab-region)
  1691. @index(entab-region) changes multiple spaces to tabs where possible. 
  1692. This is a good way to shrink the size of large documents, especially
  1693. with data tables.  Both of these commands can take a numeric argument
  1694. which will be interpreted as the number of lines to en/detab. 
  1695.  
  1696. Another function, related to those above is provided for by the @b(^X^T)
  1697. @i(trim-region)@index(trim-region) when invoked will delete any trailing
  1698. white space in the selected region.  A preceding numeric argument will do
  1699. this for that number of lines.
  1700. @newpage
  1701. @heading(Chapter @value(chapter) Summary)
  1702.  
  1703. In Chapter @value(chapter) introduced some of the formatting features of
  1704. EMACS. Text-wrap, paragraph reformatting, and tabs were discussed in
  1705. some detail.  The commands in the following table were covered in the
  1706. chapter. 
  1707.  
  1708. @begin{verbatim}
  1709.  
  1710. @u(Key Binding        Keystroke            Effect)
  1711. add-mode/WRAP        @b{^XM}[WRAP]    Add wrap mode to current buffer
  1712.  
  1713. delete-mode/WRAP    @b{^X^M}[WRAP]    Remove wrap mode from current buffer
  1714.  
  1715. set-fill-column     @b{^XF}     Set fill column to given numeric
  1716.                     argument  
  1717.  
  1718. fill-paragraph        @b{M-Q}     Logically reformats the current
  1719.                     paragraph
  1720.  
  1721. case-word-upper     @b{M-U}     Text from point to end of the
  1722.                     current word is changed to uppercase
  1723.  
  1724. case-word-lower     @b{M-L}     Text from point to end of the 
  1725.                     current word is changed to lowercase
  1726.  
  1727. case-word-capitalize    @b{M-C}     First word (or letter) after the
  1728.                     point is capitalized
  1729.  
  1730. case-region-upper    @b{^X^U}    The current region is uppercased
  1731.  
  1732. case-region-lower    @b{^X^L}    The current region is lowercased
  1733.  
  1734. handle-tab        @b{^I}        Tab interval is set to the given
  1735.                     numeric argument
  1736.  
  1737. entab-region        @b(^X^E)    Changes multiple spaces to tabs
  1738.                     characters where possible
  1739.  
  1740. detab-region        @b(^X^D)    Changes tab characters to the
  1741.                     appropriate number of spaces
  1742.  
  1743. trim-region        @b(^X^T)    Trims white space from the end
  1744.                     of the lines in the current region
  1745. @end{verbatim}
  1746. @chapter(Access to the Outside World)
  1747.  
  1748.     EMACS has the ability to interface to other programs and the
  1749. environment of the computer outside of itself.    It does this through a
  1750. series of commands that allow it to talk to the computer's @b(command
  1751. processor) @index(command processor) or @b(shell) @index(shell).  Just
  1752. what this is varies between different computers.  Under MSDOS or PCDOS
  1753. this is the @b(command.com) @index(command.com) command processor. 
  1754. Under UNIX it is the @b(csh) @index(cshell) shell.  On the Atari ST is
  1755. can be the Mark Williams @b(MSH) or the Beckmeyer shell.  In each case,
  1756. it is the part of the computer's operating system that is responsible
  1757. for determining what programs are executed, and when. 
  1758.  
  1759.     The @b(^X!) @i(shell-command) @index(shell-command) command
  1760. prompts the user for a command line to send out to the shell to execute.
  1761. This can be very useful for doing file listings and changing the
  1762. current directory or folder.  EMACS gives control to the shell, which
  1763. executed the command, and then types @b([END]) and waits for the user to
  1764. type a character before redrawing the screen and resuming editing. If
  1765. the @i(shell-command) command is used from within the macro language,
  1766. there is no pause.
  1767.  
  1768.     @b(^X@@) @i(pipe-command) @index(pipe-command) command allows
  1769. EMACS to execute a shell command, and if the particular computer allows
  1770. it, send the results into a buffer which is automatically displayed on
  1771. the screen. The resulting buffer, called "command" can be manipulated
  1772. just like any other editing buffer. Text can be copied out of it or
  1773. rearranged as needed. This buffer is originally created in @b(VIEW) mode,
  1774. so remember to @b(^X^Mview<NL>) in order to change it.
  1775.  
  1776.     Many computers provide tools which will allow you to @b(filter)
  1777. @index(filter) text, making some modifications to it along the way. A
  1778. very common tool is the @b(SORT) program which accepts a file, sorts
  1779. it, and prints the result out.  The EMACS command, @b(^X#)
  1780. @i(filter-buffer)@index(filter-buffer) sends the current buffer through
  1781. such a filter.  Therefore, if you wished to sort the current buffer on
  1782. a system which supplied a sort filter, you would type @b(^X#sort<NL>). 
  1783. You can also create your own filters by writing programs and utilities
  1784. which read text from the keyboard and display the results.  EMACS will
  1785. use any of these which would normally be available from the current
  1786. shell.
  1787.  
  1788.     If you would like to execute another program directly, without
  1789. the overhead of an intervening shell, you can use the @b(^X$)
  1790. @i(execute-program) @index(execute-program) command. It will prompt you
  1791. for an external program and its arguments and attempt to execute it. 
  1792. Like when EMACS looks for command files, EMACS will look first in the
  1793. HOME directory, then down the execute PATH, and finally in the current
  1794. directory for the named program. On some systems, it will automatically
  1795. tack the proper extension on the file name to indicate it is a program.
  1796. On some systems that don't support this function, @b(^X$) will be
  1797. equivalent to @b(^X!) @i(shell-command).
  1798.  
  1799.     Sometimes, you would like to get back to the shell and execute
  1800. other commands, without losing the current contents of EMACS.  The
  1801. @b(^XC) @i(i-shell) @index(i-shell) command shells out of EMACS,
  1802. leaving EMACS in the computer and executing another command shell.  Most
  1803. systems would allow you to return to EMACS with the "exit" command. 
  1804.  
  1805. @i(    On some systems, mainly advanced versions of UNIX, you can
  1806. direct EMACS to "go into the background" with the @b(^XD) suspend-emacs
  1807. @index(suspend-emacs) command.    This places EMACS in the background
  1808. returning you to the original command shell. EMACS can then be returned
  1809. to at any time with the "fg" foreground command.)
  1810. @newpage
  1811. @heading(Chapter @value(chapter) Summary)
  1812.  
  1813. In Chapter @value(chapter) introduced different ways to access the
  1814. computers shell or command processor from within EMACS.  The commands
  1815. in the following table were covered in the chapter. 
  1816.  
  1817. @begin{verbatim}
  1818.  
  1819. @u(Key Binding        Keystroke            Effect)
  1820. execute-program     @b(^X$)     Execute an external program
  1821.                     directly
  1822.  
  1823. filter-command        @b(^X#)     Send the current buffer through
  1824.                     a shell filter
  1825.  
  1826. i-shell         @b(^XC)     Escape to a new shell
  1827.  
  1828. pipe-command        @b(^X@@)    Send the results of an external
  1829.                     shell command to a buffer
  1830.  
  1831. shell-command        @b(^X!)     Execute one shell command
  1832.  
  1833. suspend-emacs        @b(^XD)     Place EMACS in the background
  1834.                     (some UNIX systems only)
  1835. @end{verbatim}
  1836. @chapter(Keyboard Macros)
  1837.  
  1838. In many applications, it may be necessary to repeat a series of
  1839. characters or commands frequently.  For example, a paper may require the
  1840. frequent repetition of a complex formula or a long name.  You may also
  1841. have a series of EMACS commands that you invoke frequently.  Keyboard
  1842. macros offer a convenient method of recording and repeating these
  1843. commands. 
  1844.  
  1845. Imagine, for example, you are writing a scholarly paper on @i{Asplenium
  1846. platyneuron}, the spleenwort fern.  Even the dedicated botanist would
  1847. probably find it a task bordering on the agonizing to type
  1848. @i{Asplenium platyneuron} frequently throughout the paper.  An
  1849. alternative method is 'record' the name in a keyboard macro.  Try it
  1850. yourself.
  1851.  
  1852. The command @b{^X(} @i(begin-macro) @index(begin-macro) starts
  1853. recording the all the keystrokes and commands you input.  After you've
  1854. typed it, enter @b{Asplenium platyneuron}.  To stop recording, type
  1855. @b{^X)} @i(end-macro) @index(end-macro).  EMACS has stored all the
  1856. keystrokes between the two commands.  To repeat the name you've stored,
  1857. just enter @b{^XE} @i(execute-macro) @index(execute-macro), and the
  1858. name "Asplenium platyneuron" appears.  You can repeat this action as
  1859. often as you want, and of course as with any EMACS command, you may
  1860. precede it with a numerical argument. 
  1861.  
  1862. Because EMACS records keystrokes, you may freely intermix commands and
  1863. text.  Unfortunately, you can only store one macro at a time.  Thus, if
  1864. you begin to record another macro, the previously defined macro is
  1865. lost. Be careful to ensure that you've finished with one macro before
  1866. defining another.  If you have a series of commands that you would like
  1867. to 'record' for future use, use the macro or procedure facilities
  1868. detailed in chapter <X>.
  1869. @newpage
  1870. @heading(Chapter @value(chapter) Summary)
  1871.  
  1872. Chapter @value(chapter) covered keyboard macros.  You learned how to
  1873. record keystrokes and how to repeat the stored sequence. 
  1874.  
  1875. @begin{verbatim}
  1876. @u(Key Binding        Keystroke        Effect)
  1877.  
  1878. start-macro        @b{^X(}     Starts recording all keyboard input
  1879.  
  1880. end-macro        @b{^X)}     Stops recording keystrokes for macro
  1881.  
  1882. execute-macro        @b{^XE}     Entire sequence of recorded
  1883.                     keystrokes is replayed
  1884. @end{verbatim}
  1885. @chapter(MicroEMACS Macros)
  1886.  
  1887.     Macros are programs that are used to customize the editor and to
  1888. perform complicated editing tasks.  They may be stored in files or
  1889. buffers and may be executed using an appropriate command, or bound to a
  1890. particular keystroke.  Portions of the standard start-up file are
  1891. implemented via macros, as well as the example menu system.  The
  1892. @i(execute-macro-<n>) @index(execute-macro-<n>) commands cause the
  1893. macro, numbered from 1 to 40, to be executed.  The @i(execute-file)
  1894. @index(execute-file) command allows you to execute a macro stored in a
  1895. disk file, and the @i(execute-buffer) @index(execute-buffer) command
  1896. allows you to execute a macro stored in a buffer.  Macros are stored for
  1897. easy execution by executing files that contain the store-macro command. 
  1898.  
  1899.     If you need more than 40 macros, named macroes, called
  1900. @b(procedures), @index(procedures) can be used.  The @i(store-procedure)
  1901. @index(store-procedure) command takes a string argument which is the
  1902. name of a procedure to store.  These procedures than can be executed
  1903. with the @b(M-^E) @i(execute-procedure) @index(execute-procedure) or the
  1904. @i(run) @index(run) commands.  Also, giving the name of a stored
  1905. procedure within another macro will executed that named procedure as if
  1906. it had been called up with the @i(run) command.
  1907.  
  1908.     Some fairly length examples of MicroEMACS macroes can be seen by
  1909. examining the standard files that come with EMACS.  The @b(emacs.rc)
  1910. @index(emacs.rc) file (called @b[.emacsrc]@index[.emacsrc]) under UNIX)
  1911. is the EMACS macro file which is executed when EMACS is normally run. 
  1912. It contains a number of different stored macroes along with the lines to
  1913. setup and display the Function key window @index(function key window)
  1914. and to call up other commands and macro files using function keys.
  1915.  
  1916.     There are many different aspects to the macro language within
  1917. MicroEMACS.  Editor commands are the various commands that manipulate
  1918. text, buffers, windows, et cetera, within the editor.  Directives are
  1919. commands which control what lines get executed within a macro.    Also
  1920. there are various types of variables.  Environmental variables both
  1921. control and report on different aspects of the editor.    User variables
  1922. hold string values which may be changed and inspected.    Buffer
  1923. variables allow text to be placed into variables.  Interactive variable
  1924. allow the program to prompt the user for information.  Functions can be
  1925. used to manipulate all these variables. 
  1926.  
  1927. @section(Constants)
  1928.  
  1929.     All constants and variable contents in EMACS are stored as
  1930. strings of characters. Numbers are stored digit by digit as characters.
  1931. This allows EMACS to be "typeless", not having different variables types
  1932. be legal in different contexts. This has the disadvantage of forcing the
  1933. user to be more careful about the context of the statements variables
  1934. are placed in, but in turn gives them more flexibility in where they
  1935. can place variables. Needless to say, this also allows EMACS's expression
  1936. evaluator to be both concise and quick.
  1937.  
  1938.     Wherever statements need to have arguments, it is legal to place
  1939. constants.  A constant is a double quote character, followed by a string
  1940. of characters, and terminated by another double quote character. To
  1941. represent various special characters within a constant, the tilde (~)
  1942. character is used. The character following the tilde is interpreted
  1943. according to the following table:
  1944.  
  1945. @begin(verbatim)
  1946. @u(Sequence    Result)
  1947. ~n            EMACS newline character (breaks lines)
  1948. ~r        ^M    carriage return
  1949. ~l        ^J    linefeed
  1950. ~~        ~    tilde
  1951. ~b        ^H    backspace
  1952. ~f        ^L    formfeed
  1953. ~t        ^I    tab
  1954. ~"        "    quote
  1955. @end(verbatim)
  1956.  
  1957.     Any character not in the table which follows a tilde will be
  1958. passed unmodified.  This action is similar to the @b(^Q)
  1959. @i(quote-character) command available from the keyboard. 
  1960.  
  1961.     EMACS may use different characters for line terminators
  1962. on different computers.  The ~n combination will always get the proper
  1963. line terminating sequence for the current system.
  1964.  
  1965.     The double quotes around constants are not needed if the
  1966. constant contains no internal white space and it also does not happen to
  1967. meet the rules for any other EMACS commands, directives, variables, or
  1968. functions. This is reasonable useful for numeric constants.
  1969.  
  1970. @section(Variables)
  1971.  
  1972.     Variables in MicroEMACS can be used to return values within
  1973. expressions, as repeat counts to editing commands, or as text to be
  1974. inserted into buffers and messages.  The value of these variables is set
  1975. using the set (^XA) command.  For example, to set the current fill
  1976. column to 64 characters, the following macro line would be used:
  1977.  
  1978.     set $fillcol 64
  1979.  
  1980.     or to have the contents of @b(%name) inserted at the point in the
  1981. current buffer, the command to use would be:
  1982.  
  1983.     insert-string %name
  1984. @newpage
  1985. @subsection(Environmental Variables)
  1986.  
  1987.     "What good is a quote if you can't change it?"
  1988.  
  1989.     These variables are used to change different aspects of the way
  1990. the editor works.  Also they will return the current settings if used as
  1991. part of an expression.    All environmental variable names begin with a
  1992. dollar sign ($) and are in lower case.
  1993.  
  1994. @begin(description)
  1995. $acount@\The countdown of inserted characters until the next save-file
  1996.  
  1997. $asave@\The number of inserted characters between automatic file-saves
  1998. in ASAVE mode
  1999.  
  2000. $bufhook@\The function named in this variable is run when a buffer is
  2001. entered.  It can be used to implement modes which are specific to a
  2002. paricular file or file type.
  2003.  
  2004. $cbflags@\Current buffer attribute flags (See appendix G for details)
  2005.  
  2006. $cbufname@\Name of the current buffer
  2007.  
  2008. $cfname@\File name of the current buffer
  2009.  
  2010. $cmdhook@\Name of function to run before accepting a command. This is
  2011. by default set to @i(nop)
  2012.  
  2013. $cmode@\Integer containing the mode of the current buffer. (See Appendix F
  2014. for values)
  2015.  
  2016. $curchar@\Ascii value of the character currently at the point
  2017.  
  2018. $curcol@\Current column of point in current buffer
  2019.  
  2020. $curline@\Current line of point in current buffer
  2021.  
  2022. $curwidth@\Number of columns used currently
  2023.  
  2024. $cwline@\Current display line in current window
  2025.  
  2026. $debug@\Flag to trigger macro debugging
  2027.  
  2028. $diagflag@\If set to TRUE, diagonal dragging of text and mode lines is
  2029. enabled.  If FALSE, text and modelines can only be dragged horizontally
  2030. or vertically at one time.
  2031.  
  2032. $discmd@\Flag to disable the echoing of messages on the command line
  2033.  
  2034. $disinp@\Flag to disable the echoing of characters during command line input
  2035.  
  2036. $exbhook@\This variable holds the name of a function or macro which is
  2037. run whenever you are switching out of a buffer.
  2038.  
  2039. $fcol@\The current line position being displayed in the first column of
  2040. the current window.
  2041.  
  2042. $fillcol@\Current fill column
  2043.  
  2044. $flicker@\Flicker Flag set to TRUE if IBM CGA set to FALSE for most others
  2045.  
  2046. $gflags@\Global flags controlling some EMACS internal functions (See
  2047. appendix G for details)
  2048.  
  2049. $gmode@\Global mode flags. (See Appendix F for values)
  2050.  
  2051. $hardtab@\Number of spaces between hard tab stops.  Normally 8, this can
  2052. be used to change indentation only within the editor.@index(tabs)
  2053.  
  2054. $hjump@\The number in here tells EMACS how many columns to scroll the
  2055. screen horizontally when a horizontal scroll is required.
  2056.  
  2057. $hscroll@\This flag determines if EMACS will scroll the entire current
  2058. window horizontally, or just the current line.    The default value, TRUE,
  2059. results in the entire current window being shifted left and right when
  2060. the cursor goes off the edge of the screen.
  2061.  
  2062. $kill@\This contains the first 127 characters currently in the kill
  2063. buffer and can be used to set the contents of the kill buffer
  2064.  
  2065. $language@\[READ ONLY]Contains the name of the language which the
  2066. current EMACS's message will display.  (Currently EMACS is available in
  2067. English, French, Spanish, Pig Latin, Portuguese, Dutch, German and
  2068. Esperonto).
  2069.  
  2070. $lastkey@\[READ ONLY]Last keyboard character typed
  2071.  
  2072. $lastmesg@\[READ ONLY]Contains the text of the last message which
  2073. emacs wrote on the command line
  2074.  
  2075. $line@\The current line in the current buffer can be retrieved and
  2076. set with this environment variable
  2077.  
  2078. $lwidth@\[READ ONLY]Returns the number of characters in the current line
  2079.  
  2080. $match@\[READ ONLY]Last string matched in a magic mode search
  2081.  
  2082. $modeflag@\Determines if mode lines are currently displayed
  2083.  
  2084. $msflag@\If TRUE, the mouse (if present) is active.  If FALSE, no mouse
  2085. cursor is displayed, and no mouse actions are taken.@index(mouse)
  2086.  
  2087. $pagelen@\Number of screen lines used currently
  2088.  
  2089. $palette@\string used to control the palette register settings on
  2090. graphics versions.  The usually form consists of groups of three octal
  2091. digits setting the red, green, and blue levels.@index(color pallette)
  2092.  
  2093. $pending@\[READ ONLY]Flag to determine if there are user keystrokes
  2094. waiting to be processed.
  2095.  
  2096. $progname@\[READ ONLY]Always contains the string "MicroEMACS" for
  2097. standard MicroEMACS.  Could be something else if EMACS is incorporated
  2098. as part of someone else's program
  2099.  
  2100. $readhook@\This variable holds the name of a function to execute
  2101. whenever a file is read into EMACS.  Normally, using the standard
  2102. @b(emacs.rc) file, this is bound to a function which places EMACS into
  2103. CMODE if the extension of the file read is .c or .h
  2104.  
  2105. $replace@\Current default replace string
  2106.  
  2107. $rval@\This contains the return value from the last subprocess which was
  2108. invoked from EMACS
  2109.  
  2110. $search@\Current default search string
  2111.  
  2112. $seed@\Integer seed of the random number generator
  2113.  
  2114. $softtab@\Number of spaces inserted by EMACS when the handle-tab command
  2115. (which is normally bound to the TAB key) is invoked.@index(tabs)
  2116.  
  2117. $sres@\Current screen resolution (CGA, MONO, EGA or VGA on the IBM-PC
  2118. driver.  LOW, MEDIUM, HIGH or DENSE on the Atari ST1040, NORMAL on all
  2119. others)@index(screen resolution)
  2120.  
  2121. $ssave@\If TRUE, when EMACS is asked to save the current file, it
  2122. writes all files out to a temporary file, deletes the original, and
  2123. then renames the temporary to the old file name.  The default value of
  2124. this is TRUE.
  2125.  
  2126. $sscroll@\Changes EMACS, when set to TRUE, to smoothly scroll windows
  2127. (one line at a time) when cursoring off the ends of the current
  2128. window.
  2129.  
  2130. $status@\[READ ONLY]Status of the success of the last command (TRUE or
  2131. FALSE).  This is usually used with !force to check on the success of a
  2132. search, or a file operation. 
  2133.  
  2134. $sterm@\This is the character used to terminate search string inputs.
  2135. The default for this is the last key bound to @i(meta-prefix)
  2136.  
  2137. $target@\Current target for line moves (setting this fool's EMACS into
  2138. believing the last command was a line move)
  2139.  
  2140. $time@\[READ ONLY]Contains a string corresponding to the current date
  2141. and time.  Usually this is in a form similar to "Mon May 09 10:10:58 1988".
  2142. Not all operating systems will support this.
  2143.  
  2144. $tpause@\Controls the length of the pause to display a matched fence
  2145. when the current buffer is in CMODE and a close fence has been typed
  2146.  
  2147. $version@\[READ ONLY]Contains the current MicroEMACS version number
  2148.  
  2149. $wline@\Number of display lines in current window
  2150.  
  2151. $wraphook@\This variable contains the name of an EMACS function which is
  2152. executed when a buffer is in WRAP mode and it is time to wrap.    By
  2153. default this is bound to @i(wrap-word).
  2154.  
  2155. $writehook@\This variable contains the name of an EMACS function or
  2156. macro which is invoked whenever EMACS attempts to write a file out to
  2157. disk.  This is executed before the file is written, allowing you to
  2158. process a file on the way out.
  2159.  
  2160. $xpos@\The column the mouse was at the last mouse button press
  2161.  
  2162. $ypos@\The line which the mouse was on during the last mouse button press
  2163. @end(description)
  2164.  
  2165.     Obviously, many more of these variables will be available in
  2166. future releases of MicroEMACS. (Yes, send a vote for your favorite new
  2167. environmental variables today).
  2168.  
  2169. @subsection(User variables)
  2170.  
  2171.     User variables allow you, the user, to store strings and
  2172. manipulate them.  These strings can be pieces of text, numbers (in text
  2173. form), or the logical values @b(TRUE) and @b(FALSE).  These variables
  2174. can be combined, tested, inserted into buffers, and otherwise used to
  2175. control the way your macros execute.  At the moment, up to 255 user
  2176. variables may be in use in one editing session.  All users variable
  2177. names must begin with a percent sign (%) and may contain any printing
  2178. characters.  Only the first 10 characters are significant (IE
  2179. differences beyond the tenth character are ignored).  Most operators
  2180. will truncate strings to a length of 128 characters. 
  2181.  
  2182. @subsection(Buffer Variables)
  2183.  
  2184.     Buffer variables are special in that they can only be queried
  2185. and cannot be set.  What buffer variables are is a way to take text from
  2186. a buffer and place it in a variable. For example, if I have a buffer by
  2187. the name of RIGEL2, and it contains the text:
  2188.  
  2189. @begin(verbatim)
  2190. @begin(group)
  2191.     Richmond
  2192.     Lafayette
  2193.     <*>Bloomington        (where <*> is the current point)
  2194.     Indianapolis
  2195.     Gary
  2196.     =* MicroEMACS 3.10 (WRAP) == rigel2 == File: /data/rigel2.txt =====
  2197. @end(group)
  2198. @end(verbatim)
  2199.  
  2200.     and within a command I reference #rigel2, like:
  2201.  
  2202.     insert-string #rigel2
  2203.  
  2204.     MicroEMACS would start at the current point in the RIGEL2
  2205. buffer and grab all the text up to the end of that line and pass that
  2206. back.  Then it would advance the point to the beginning of the next line.
  2207. Thus, after our last command executes, the string "Bloomington" gets
  2208. inserted into the current buffer, and the buffer RIGEL2 now looks like
  2209. this:
  2210.  
  2211. @begin(verbatim)
  2212. @begin(group)
  2213.     Richmond
  2214.     Lafayette
  2215.     Bloomington
  2216.     <*>Indianapolis     (where <*> is the current point)
  2217.     Gary
  2218.     =* MicroEMACS 3.10 (WRAP) == rigel2 == File: /data/rigel2.txt =====
  2219. @end(group)
  2220. @end(verbatim)
  2221.  
  2222.     as you have probably noticed, a buffer variable consists of the
  2223. buffer name, preceded by a pound sign (#).
  2224.  
  2225. @subsection(Interactive variables)
  2226.  
  2227.     Interactive variables are actually a method to prompt the user
  2228. for a string.  This is done by using an at sign (@@) followed either with
  2229. a quoted string, or a variable containing a string.  The string is the
  2230. placed on the bottom line, and the editor waits for the user to type in
  2231. a string.  Then the string typed in by the users is returned as the
  2232. value of the interactive variable.  For example:
  2233.  
  2234. @begin(verbatim)
  2235.     set %quest "What file? "
  2236.     find-file @@%quest
  2237. @end(verbatim)
  2238.  
  2239.     will ask the user for a file name, and then attempt to find it.
  2240. Note also that complex expressions can be built up with these
  2241. operators, such as:
  2242.  
  2243. @verbatim(@@&cat &cat "File to decode[" %default "]: ")
  2244.  
  2245.     which prompts the user with the concatenated string.
  2246.  
  2247. @section(Functions)
  2248.  
  2249.     Functions can be used to manipulate variables in various ways. 
  2250. Functions can have one, two, or three arguments.  These arguments will
  2251. always be placed after the function on the current command line.  For
  2252. example, if we wanted to increase the current fill column by two, using
  2253. emacs's set (^XA) command, we would write:
  2254.  
  2255. @begin(group)
  2256. @begin(verbatim)
  2257.     set $fillcol &add $fillcol 2
  2258.      \    \      \      \     \____second operand
  2259.       \     \    \      \_________first operand
  2260.        \      \     \_______________function to execute
  2261.         \       \_____________________variable to set
  2262.          \___________________________set (^XA) command
  2263. @end(verbatim)
  2264. @end(group)
  2265.  
  2266.     Function names always begin with the ampersand (&) character,
  2267. and are only significant to the first three characters after the
  2268. ampersand.  Functions will normal expect one of three types of
  2269. arguments, and will automatically convert types when needed.
  2270.  
  2271. @begin(description)
  2272. <num>@\an ascii string of digits which is interpreted as a numeric value. 
  2273. Any string which does not start with a digit or a minus sign (-) will be
  2274.  
  2275. considered zero. 
  2276.  
  2277. <str>@\An arbitrary string of characters.  At the moment, strings are
  2278. limited to 128 characters in length. 
  2279.  
  2280. <log>@\A logical value consisting of the string "TRUE" or "FALSE". 
  2281. Numeric strings will also evaluate to "FALSE" if they are equal to zero,
  2282. and "TRUE" if they are non-zero.  Arbitrary text strings will have the
  2283. value of "FALSE". 
  2284. @end(description)
  2285.  
  2286.     A list of the currently available functions follows: (Once
  2287. again, send in those votes on what kind of functions you would like to
  2288. see added!) Functions are always used in lower case, the uppercase
  2289. letters in the function table are the short form of the function (IE
  2290. &div for ÷).
  2291.  
  2292. @begin(verbatim)
  2293. Numeric Functions:    (returns <num>)
  2294.  
  2295. &ADD        <num> <num>    Add two numbers
  2296. &SUB        <num> <num>    Subtract the second number from the first
  2297. &TIMes        <num> <num>    Multiply two numbers
  2298. &DIVide     <num> <num>    Divide the first number by the second
  2299.                 giving an integer result
  2300. &MOD        <num> <num>    Return the reminder of dividing the
  2301.                 first number by the second
  2302. &NEGate     <neg>        Multiply the arg by -1
  2303. &LENgth     <str>        Returns length of string
  2304. &SINdex     <str1> <str2>    Finds the position of <str2> within
  2305.                 <str1>. Returns zero if not found.
  2306. &ASCii        <str>        Return the ascii code of the first
  2307.                 character in <str>
  2308. &RND        <num>        Returns a random integer between 1 and <num>
  2309. &ABS        <num>        Returns the absolute value of <num>
  2310. &BANd        <num> <num>    Bitwise AND function
  2311. &BOR        <num> <num>    Bitwise OR function
  2312. &BXOr        <num> <num>    Bitwise XOR function
  2313. &BNOt        <num>        Bitwise NOT function
  2314.  
  2315. String manipulation functions:    (returns <str>)
  2316.  
  2317. &CAT        <str> <str>    Concatenate the two strings to form one
  2318. &LEFt        <str> <num>    return the <num> leftmost characters
  2319.                 from <str>
  2320. &RIGht        <str> <num>    return the <num> rightmost characters
  2321.                 from <str>
  2322. &MID        <str> <num1> <num2>
  2323.                 Starting from <num1> position in <str>,
  2324.                 return <num2> characters.
  2325. &UPPer        <str>        Uppercase <str>
  2326. &LOWer        <str>        lowercase <str>
  2327. &CHR        <num>        return a string with the character
  2328.                 represented by ascii code <num>
  2329. >C                returns a string of characters
  2330.                 containing a EMACS command input from
  2331.                 the user
  2332. >K                return a string containing a single
  2333.                 keystroke from the user
  2334. &ENV        <str>        If the operating system is capable, this
  2335.                 returns the environment string associated
  2336.                 with <str>
  2337. &BIND        <str>        return the function name bound to the
  2338.                 keystroke <str>
  2339. &XLATE        <str1> <str2> <str3>
  2340. &FINd        <str>        Find the named file <str> along the
  2341.                 path and return its full file specification
  2342.                 or an empty string if none exists
  2343. &TRIM        <str>        Trim the trailing whitespace from a string
  2344.  
  2345. Logical Testing functions:    (returns <log>)
  2346.  
  2347. &NOT        <log>        Return the opposite logical value
  2348. &AND        <log1> <log2>    Returns TRUE if BOTH logical arguments
  2349.                 are TRUE
  2350. &OR        <log1> <log2>    Returns TRUE if either argument
  2351.                 is TRUE
  2352. &EQUal        <num> <num>    If <num> and <num> are numerically
  2353.                 equal, return TRUE
  2354. &LESs        <num1> <num2>    If <num1> is less than <num2>, return
  2355.                 TRUE.
  2356. &GREater    <num1> <num2>    If <num1> is greater than, or equal to
  2357.                 <num2>, return TRUE.
  2358. &SEQual     <str1> <str2>    If the two strings are the same, return
  2359.                 TRUE.
  2360. &SLEss        <str1> <str2>    If <str1> is less alphabetically than
  2361.                 <str2>, return TRUE.
  2362. &SGReater    <str1> <str2>    If <str1> is alphabetically greater than
  2363.                 or equal to <str2>, return TRUE.
  2364. &EXIst        <str>        Does the named file <str> exist?
  2365.  
  2366. Special Functions:
  2367.  
  2368. &INDirect    <str>        Evaluate <str> as a variable.
  2369. @end(verbatim)
  2370.  
  2371.     This last function deserves more explanation. The &IND function
  2372. evaluates its argument, takes the resulting string, and then uses it as
  2373. a variable name.  For example, given the following code sequence:
  2374.  
  2375. @begin(verbatim)
  2376.     ; set up reference table
  2377.  
  2378.     set %one    "elephant"
  2379.     set %two    "giraffe"
  2380.     set %three    "donkey"
  2381.  
  2382.     set %index "two"
  2383.     insert-string &ind %index
  2384. @end(verbatim)
  2385.  
  2386.     the string "giraffe" would have been inserted at the point in
  2387. the current buffer.  This indirection can be safely nested up to about
  2388. 10 levels.
  2389.  
  2390. @section(Directives)
  2391.  
  2392.     Directives are commands which only operate within an executing
  2393. macro, IE they do not make sense as a single command. As such, they
  2394. cannot be called up singly or bound to keystroke. Used within macros,
  2395. they control what lines are executed and in what order.
  2396.  
  2397.     Directives always start with the exclamation mark (!) character
  2398. and must be the first thing placed on a line.  Directives executed
  2399. interactively (via the execute-command-line command) will be ignored. 
  2400.  
  2401. @subsection(!ENDM Directive)
  2402.  
  2403.     This directive is used to terminate a macro being stored. For
  2404. example, if a file is being executed contains the text:
  2405.  
  2406. @begin(verbatim)
  2407.     ;    Read in a file in view mode, and make the window red
  2408.  
  2409.     26    store-macro
  2410.         find-file @@"File to view: "
  2411.         add-mode "view"
  2412.         add-mode "red"
  2413.     !endm
  2414.  
  2415.     write-message "[Consult macro has been loaded]"
  2416. @end(verbatim)
  2417.  
  2418.     only the lines between the store-macro command and the !ENDM
  2419. directive are stored in macro 26.  Both numbered macroes and named
  2420. procedures (via the @i(store-procedure) command) should be terminated with
  2421. this directive.
  2422.  
  2423. @subsection(!FORCE Directive)
  2424.  
  2425.     When MicroEMACS executes a macro, if any command fails, the
  2426. macro is terminated at that point. If a line is preceded by a !FORCE
  2427. directive, execution continues whether the command succeeds or not. For
  2428. example:
  2429.  
  2430. @begin(verbatim)
  2431.     ;    Merge the top two windows
  2432.  
  2433.     save-window        ;remember what window we are at
  2434.     1 next-window        ;go to the top window
  2435.     delete-window        ;merge it with the second window
  2436.     !force restore-window    ;This will continue regardless
  2437.     add-mode "red"
  2438. @end(verbatim)
  2439.  
  2440. @subsection(!IF, !ELSE, and !ENDIF Directives)
  2441.  
  2442.     This directive allows statements only to be executed if a
  2443. condition specified in the directive is met.  Every line following the
  2444. !IF directive, until the first !ELSE or !ENDIF directive, is only
  2445. executed if the expression following the !IF directive evaluates to a
  2446. TRUE value.  For example, the following macro segment creates the
  2447. portion of a text file automatically.  (yes believe me, this will be
  2448. easier to understand then that last explanation....)
  2449.  
  2450. @begin(verbatim)
  2451.     !if &sequal %curplace "timespace vortex"
  2452.         insert-string "First, rematerialize~n"
  2453.     !endif
  2454.     !if &sequal %planet "earth"    ;If we have landed on earth...
  2455.         !if &sequal %time "late 20th century"  ;and we are then
  2456.             write-message "Contact U.N.I.T."
  2457.         !else
  2458.             insert-string "Investigate the situation....~n"
  2459.             insert-string "(SAY 'stay here Sara')~n"
  2460.         !endif
  2461.     !else
  2462.         set %conditions @@"Atmosphere conditions outside? "
  2463.         !if &sequal %conditions "safe"
  2464.             insert-string &cat "Go outside......" "~n"
  2465.             insert-string "lock the door~n"
  2466.         !else
  2467.             insert-string "Dematerialize..try somewhen else"
  2468.             newline
  2469.         !endif
  2470.     !endif
  2471. @end(verbatim)
  2472.  
  2473. @subsection(!GOTO Directive)
  2474.  
  2475.     Flow can be controlled within a MicroEMACS macro using the !GOTO
  2476. directive. It takes as an argument a label. A label consists of a line
  2477. starting with an asterisk (*) and then an alphanumeric label.  Only
  2478. labels in the currently executing macro can be jumped to, and trying to
  2479. jump to a non-existing label terminates execution of a macro.  For
  2480. example..
  2481.  
  2482. @begin(verbatim)
  2483.     ;Create a block of DATA statements for a BASIC program
  2484.  
  2485.         insert-string "1000 DATA "
  2486.         set %linenum 1000
  2487.  
  2488.     *nxtin
  2489.         update-screen        ;make sure we see the changes
  2490.         set %data @@"Next number: "
  2491.         !if &equal %data 0
  2492.             !goto finish
  2493.         !endif
  2494.  
  2495.         !if &greater $curcol 60
  2496.             2 delete-previous-character
  2497.             newline
  2498.             set %linenum &add %linenum 10
  2499.             insert-string &cat %linenum " DATA "
  2500.         !endif
  2501.  
  2502.         insert-string &cat %data ", "
  2503.         !goto nxtin
  2504.  
  2505.     *finish
  2506.  
  2507.         2 delete-previous-character
  2508.         newline
  2509. @end(verbatim)
  2510.  
  2511. @subsection(!WHILE and !ENDWHILE Directives)
  2512.  
  2513.     This directive allows you to set up repetitive tasks easily and
  2514. efficiently. If a group of statements need to be executed while a
  2515. certain condition is true, enclose them with a while loop. For example,
  2516.  
  2517. @begin(verbatim)
  2518.     !while &less $curcol 70
  2519.         insert-string &cat &cat "[" #stuff "]"
  2520.     !endwhile
  2521. @end(verbatim)
  2522.  
  2523.     places items from buffer "item" in the current line until the
  2524. cursor is at or past column 70.  While loops may be nested and can
  2525. contain and be the targets of !GOTOs with no ill effects. Using a while
  2526. loop to enclose a repeated task will run much faster than the
  2527. corresponding construct using !IFs.
  2528.  
  2529. @subsection(!BREAK Directive)
  2530.  
  2531.     This directive allows the user to abort out of the currently
  2532. most inner while loop, regardless of the condition.  It is often used
  2533. to abort processing for error conditions.  For example:
  2534.  
  2535. @begin(verbatim)
  2536. ;    Read in files and substitute "begining" with "beginning"
  2537.  
  2538.     set %filename #list
  2539.     !while ¬ &seq %filename "<end>"
  2540. !force        find-file %filename
  2541.         !if &seq $status FALSE
  2542.             write-message "[File read error]"
  2543.             !break
  2544.         !endif
  2545.         beginning-of-file
  2546.         replace-string "begining" "beginning"
  2547.         save-file
  2548.         set %filename #list
  2549.     !endwhile
  2550. @end(verbatim)
  2551.  
  2552.     This while loop will process files until the list is exhausted
  2553. or there is an error while reading a file.
  2554.  
  2555. @subsection(!RETURN Directive)
  2556.  
  2557.     The !RETURN Directive causes the current macro to exit, either
  2558. returning to the caller (if any) or to interactive mode.  For example:
  2559.  
  2560. @begin(verbatim)
  2561.     ;    Check the monitor type and set %mtyp
  2562.  
  2563.     !if &sres "CGA"
  2564.         set %mtyp 1
  2565.         !return
  2566.     !else
  2567.         set %mtyp 2
  2568.     !endif
  2569.  
  2570.     insert-string "You are on a MONOCHROME machine!~n"
  2571. @end(verbatim)
  2572. @chapter(Debugging MicroEMACS macroes)
  2573.  
  2574.     @index(debugging)@index($debug)When developing new macroes, it
  2575. is very convenient to be able to trace their execution to find errors. 
  2576. The $debug environment variable enables macro debugging.  While this
  2577. variable is TRUE, emacs will stop at each macro line it intends to
  2578. execute and allow you to view it, and issue a number of different
  2579. commands to help determine how the macro is executing.
  2580.  
  2581.     For example, we will step through the macro which toggles the
  2582. function key window off.  The first thing to do, is to set $debug, using
  2583. the @b(^XA) @i(set) command.  Type ^XA and emacs will prompt you on the
  2584. command line with "Variable to set: ".    Type in "$debug" and press the
  2585. enter key.  Emacs will then ask "Value: ".  Type in "TRUE" (in capital
  2586. letters) and press the enter key.
  2587.  
  2588.     While macro debugging is enabled (as it is now) emacs will
  2589. report each time a variable is assigned a value, by displaying the
  2590. variable and its value on the command line.  Right now,
  2591.  
  2592. @flushleft{((($debug <- TRUE)))}
  2593.  
  2594.     appears on the command line to tell you that $debug now has been
  2595. assigned the value of TRUE.  Press the space bar to continue.
  2596.  
  2597.     Now, lets try to debug a macro.  Press function key 5 which
  2598. normally toggles the function key window.  The first thing that appears
  2599. is:
  2600.  
  2601. @flushleft{<<<[Macro 01]:!if %rcfkeys>>>}
  2602.  
  2603.     At this point, emacs is waiting for a command.    It is prepared
  2604. to see if the user variable %rcfkeys is TRUE, and execute some lines if
  2605. they are.  Suppose we want to see the value of this variable, type the
  2606. letter "e" to evaluate an expression.  Emacs will prompt with "EXP: ". 
  2607. Type "%rcfkeys" followed by the enter key.  Emacs should then respond
  2608. with "TRUE" to indicate that the function key window is currently on
  2609. screen.
  2610.  
  2611.     Press the space bar to allow the !if directive to execute. 
  2612. Emacs will decide that it is TRUE, and then display the next macro
  2613. command to execute.
  2614.  
  2615. @flushleft{<<<[Macro 01]:!goto rcfoff>>>}
  2616.  
  2617.     Notice emacs tells us what macro we are currently executing (in
  2618. this case, the macro bound to execute-macro-1).  Press the space bar
  2619. again to execute the !goto directive.
  2620.  
  2621. @flushleft{<<<[Macro 01]:save-window>>>}
  2622.  
  2623.     Emacs is saving the position of the current window so that it
  2624. can attempt to return to it after it has brought up the function key window.
  2625.  
  2626. [...THIS CHAPTER IS NOT FINISHED...]
  2627. @chapter(Key Bindings, What they are and why)
  2628.  
  2629.     One of the features which makes MicroEMACS very adaptable is its
  2630. ability to use different keystrokes to execute different commands.  The
  2631. process of changing the particular command a key invokes is called
  2632. @i(rebinding)@index(rebinding). This allows us to make the editor
  2633. look like other popular editors and programs.
  2634.  
  2635.     Each command in MicroEMACS has a name which is used for binding
  2636. purposes.  For example, the command to move the cursor down one page is
  2637. called @i(next-line) and is normally bound to the ^N key.  If you
  2638. decided that you also wanted to use the ^D key to move the cursor down
  2639. one line, you would use the M-K @i(bind-to-key)@index(bind-to-key)
  2640. command.  EMACS would respond with ": bind-to-key " on the command line
  2641. and allow you to type in a command name.  Then type in the name of the
  2642. command  you want to change, in this case @i(next-line),
  2643. followed by the <NL> key.  EMACS will then wait for you to type in the
  2644. keys you want to activate the named function.  Type a single ^D.  From
  2645. now on, typing ^D will cause EMACS to move down one line, rather than
  2646. its original function of deleting characters.
  2647.  
  2648.     To find out the name of a command, consult the list of
  2649. valid EMACS commands in Appendix B.  Also, you can use the ^X?
  2650. @i(describe-key)@index(describe-key) command to look up the name of a
  2651. command.  Type ^X? and then the key to use that command, and EMACS will
  2652. show you the name of the command.
  2653.  
  2654.     After you have experimented with changing your key bindings, you
  2655. may decide that you want to change some bindings permanently.  To have
  2656. EMACS rebind keys to your pleasure each time you start EMACS, you can
  2657. add statements to the end of your startup file (@b(emacs.rc) or
  2658. @b(.emacsrc) depending on the system).    For example,
  2659.  
  2660. bind-to-key next-line ^D
  2661.  
  2662.     Notice, that control D character in the startup file is
  2663. represented visibly as an uparrow key followed by a capital D.    To know
  2664. how to represent any keys you want to bind, use the @i(describe-key)
  2665. command on the key, and use the sequence that is displayed.
  2666.  
  2667. bind-to-key split-current-window FN1
  2668.  
  2669.     This example would make function key 1 activate the command
  2670. that splits the current window in two.  
  2671.  
  2672.     EMACS will let you define a large number of keys, but will report 
  2673. "Binding table FULL!" when it runs out of space to bind keys.  Normally 
  2674. EMACS will allow up to 512 key bindings (including approx. 300 originally 
  2675. bound keys).
  2676.  
  2677.     If you want to get a current listing of all the commands and
  2678. the keys bound to them, use the @i(describe-bindings)
  2679. @index(describe-bindings) command.  Notice, that this command is not
  2680. bound to any keys!
  2681.  
  2682. @appendix(MicroEMACS Command Line Switches and Startup Files)
  2683.  
  2684. @index(startup files)
  2685.     When EMACS first executes, it always searches for a file,
  2686. called @b(.emacsrc) @i(under most UNIX systems) or @b(emacs.rc) @i(on
  2687. most other systems) @index(emacs.rc) @index(.emacsrc) which it will
  2688. execute as EMACS macros before it reads in the named source files. This
  2689. file normally contains EMACS macroes to bind the function keys to
  2690. useful functions and load various useful macros.  The contents of this
  2691. file will probably vary from system to system and can be modified by the
  2692. user as desired.
  2693.  
  2694.     When searching for this file, EMACS looks for it in this order. 
  2695. First, it attempts to find a definition for "@b(HOME)" in the
  2696. environment.  It will look in that directory first.  Then it searches
  2697. all the directories listed in the "@b(PATH)" environment variable.  Then
  2698. it looks through a list of predefined standard directories which vary
  2699. from system to system.    Finally, failing all of these, it looks in the
  2700. current directory.  This is also the same method EMACS uses to look up
  2701. any files to execute, and to find it's help file @b(EMACS.HLP). 
  2702. @index(PATH environment variable) @index(HOME environment variable)
  2703. @index(Help File)
  2704.  
  2705. @index(switches)
  2706.     On computers that call up EMACS via a command line process, such
  2707. as MSDOS and UNIX, there are different things that can be added to the
  2708. command line to control the way EMACS operates. These can be switches,
  2709. which are a dash ('-') followed by a letter, and possible other
  2710. parameters, or a startup file specifier, which is an at sign '@@'
  2711. followed by a file name.
  2712.  
  2713. @begin(description)
  2714. @@<file>@\This causes the named file to be executed instead of the
  2715. standard emacs.rc file before emacs reads in any other files.  More than
  2716. one of these can be placed on the command line, and they will be
  2717. executed in the order that they appear. 
  2718.  
  2719. -C@\The following source files on the command line can be changed (as
  2720. opposed to being in VIEW mode). This is mainly used to cancel the
  2721. effects of the -v switch used previously in the same command line.
  2722.  
  2723. -E@\This flag causes emacs to automatically run the startup file
  2724. "error.cmd" instead of emacs.rc. This is used by various C compilers for
  2725. error processing (for example, Mark Williams C). @index(error parsing)
  2726.  
  2727. -G<num>@\Upon entering EMACS, position the cursor at the <num> line of
  2728. the first file.
  2729.  
  2730. -I<var> <value>@\Initialize an EMACS variable with <value>. This can be
  2731. useful to force EMACS to start in a particular mode.  (For example,
  2732. invoke EMACS with "emacs -i$sres VGA foo.bar" to edit file foo.bar
  2733. in VGA 50 line mode on an IBM-PC).
  2734.  
  2735. -K<key>@\This key tells emacs to place the source files in CRYPT
  2736. @index(CRYPT mode) mode and read it in using <key> as the encryption
  2737. key.  If no key is listed immediately after the -K switch, EMACS will
  2738. prompt for a key, and not echo it as it is typed. 
  2739.  
  2740. -R@\This places EMACS in "restricted mode"@index(restricted mode)
  2741. @index(BBS) where any commands allowing the user to read or write any
  2742. files other than the ones listed on the command line are disabled. Also
  2743. all commands allowing the user access to the operating system are
  2744. disabled. This makes EMACS very useful as a "safe" environment for use
  2745. within other applications and especially used as a remote editor for a
  2746. BBS or electronic bulletin board system.
  2747.  
  2748. -S<string>@\After EMACS is started, it automatically searches for
  2749. <string> in the first source file.
  2750.  
  2751. -V@\This tells EMACS that all the following sources files on the command
  2752. line should be in VIEW mode to prevent any changes being made to them.
  2753. @end(description)
  2754. @chapter(Command Completion)
  2755.  
  2756.     Some versions of MicroEMACS will allow you to abbrieviate buffer
  2757. names, command names and file names as you enter them.  To use this,
  2758. type in the first few characters of the name you wish, and then hit
  2759. either the space bar, the META key or the TAB key.  MicroEMACS will then
  2760. attempt to look at the list of all the availible names and if there is
  2761. only one which will fit, it will choose that name.  If there are several
  2762. names that quailify, as many characters as are common to ALL of them
  2763. will be entered.  If there are no possible matches, the bell will ring
  2764. to indicate MicroEMACS can not complete the command.
  2765.  
  2766.     For example, if you have several files in your current directory
  2767. with the following names:
  2768.  
  2769. @begin(verbatim)
  2770.     prog1.c
  2771.     prog1.obj
  2772.     prog1.exe
  2773.     prog1.doc
  2774.     program.one
  2775.     project.one
  2776.     test.c
  2777.     tes
  2778. @end(verbatim)
  2779.  
  2780.     and you enter the @b(^X^F) @i(find-file) command, if you type
  2781. 'p' and then hit the space bar, EMACS will respond by typing the 'r'
  2782. that is common to all the above file names begining with 'p'.  If you
  2783. then type 'ogr' and hit the tab key, EMACS will respond with 'am.one'
  2784. and automatically hit the enter key for you.
  2785.  
  2786.     If you were to instead type an 'a' and hit the space bar, EMACS
  2787. will beep, informing you that there is no possible match.
  2788.  
  2789.     If you type a 'te' and hit the space bar, EMACS will then type
  2790. the following 's', but it will not automatically enter it because it is
  2791. possible you mean to get to the test.c file.
  2792.  
  2793.     Buffer name, and command name completion is available in all
  2794. versions of MicroEMACS.  File name completion is available on UNIX
  2795. BSD4.3, the Atari ST, the AMIGA and under MSDOS.
  2796. @appendix(MicroEMACS commands)
  2797.  
  2798.     Below is a complete list of the commands in EMACS, the keys
  2799. normally used to do the command, and what the command does.  Remember,
  2800. on some computers there may also be additional ways of using a command
  2801. (cursor keys and special function keys for example). 
  2802.  
  2803. @begin(verbatim)
  2804. @u(Command            Binding     Meaning)
  2805. abort-command         ^G    This allows the user to abort out of any
  2806.                 command that is waiting for input
  2807.  
  2808. add-mode         ^XM    Add a mode to the current buffer
  2809.  
  2810. add-global-mode      M-M    Add a global mode for all new buffers
  2811.  
  2812. apropos          M-A    List out commands whose name contains
  2813.                 the string specified
  2814.  
  2815. backward-character     ^B    Move one character to the left
  2816.  
  2817. begin-macro         ^X(    Begin recording a keyboard macro
  2818.  
  2819. beginning-of-file     M-<    Move to the beginning of the file in
  2820.                 the current buffer
  2821.  
  2822. beginning-of-line     ^A    Move to the beginning of the current line
  2823.  
  2824. bind-to-key         M-K    Bind a key to a function
  2825.  
  2826. buffer-position      ^X=    List the position of the cursor in the
  2827.                 current window on the command line
  2828.  
  2829. case-region-lower     ^X^L    Make a marked region all lower case
  2830.  
  2831. case-region-upper     ^X^U    Make a marked region all upper case
  2832.  
  2833. case-word-capitalize     M-C    Capitalize the following word
  2834.  
  2835. case-word-lower      M-L    Lower case the following word
  2836.  
  2837. case-word-upper      M-U    Upper case the following word
  2838.  
  2839. change-file-name     ^XN    Change the name of the file in the
  2840.                 current buffer
  2841.  
  2842. change-screen-size    (none)    Change the number of lines of the screen
  2843.                 currently being used
  2844.  
  2845. change-screen-width    (none)    Change the number of columns of the
  2846.                 screen currently being used
  2847.  
  2848. clear-and-redraw     ^L    Clear the physical screen and redraw it
  2849.  
  2850. clear-message-line    (none)    Clear the command line
  2851.  
  2852. copy-region         M-W    Copy the currently marked region into
  2853.                 the kill buffer
  2854.  
  2855. count-words         M-^C    Count how many words, lines and
  2856.                 characters are in the current marked region
  2857.  
  2858. ctlx-prefix         ^X    Change the key used as the ^X prefix
  2859.  
  2860. delete-blank-lines     ^X^O    Delete all blank lines around the cursor
  2861.  
  2862. delete-buffer         ^XK    Delete a buffer which is not being
  2863.                 currently displayed in a window
  2864.  
  2865. delete-mode         ^X^M    Turn off a mode in the current buffer
  2866.  
  2867. delete-global-mode     M-^M    Turn off a global mode
  2868.  
  2869. delete-next-character     ^D    Delete the character following the cursor
  2870.  
  2871. delete-next-word     M-D    Delete the word following the cursor
  2872.  
  2873. delete-other-windows     ^X1    Make the current window cover the entire
  2874.                 screen
  2875.  
  2876. delete-previous-character^H    Delete the character to the left of the
  2877.                 cursor
  2878.  
  2879. delete-previous-word     M-^H    Delete the word to the left of the cursor
  2880.  
  2881. delete-window         ^X0    Remove the current window from the screen
  2882.  
  2883. describe-bindings    (none)    Make a list of all legal commands
  2884.  
  2885. describe-key         ^X?    Describe what command is bound to a
  2886.                 keystroke sequence
  2887.  
  2888. detab-region         ^X^D    Change all tabs in a region to the
  2889.                 equivalent spaces
  2890.  
  2891. display         ^XG    Prompts the user for a variable and
  2892.                 displays its current value
  2893.  
  2894. dump-variables         none    Places into a buffer the current values
  2895.                 of all environment and user variables
  2896.  
  2897. end-macro         ^X)    stop recording a keyboard macro
  2898.  
  2899. end-of-file         M->    Move cursor to the end of the current buffer
  2900.  
  2901. end-of-line         ^E    Move to the end of the current line
  2902.  
  2903. entab-region         ^X^E    Change multiple spaces to tabs where
  2904.                 possible
  2905.  
  2906. exchange-point-and-mark  ^X^X    Move cursor to the last marked spot,
  2907.                 make the original position be marked
  2908.  
  2909. execute-buffer        (none)    Execute a buffer as a macro
  2910.  
  2911. execute-command-line    (none)    Execute a line typed on the command
  2912.                 line as a macro command
  2913.  
  2914. execute-file        (none)    Execute a file as a macro
  2915.  
  2916. execute-macro         ^XE    Execute the keyboard macro (play back
  2917.                 the recorded keystrokes)
  2918. execute-macro-<n>    (none)    Execute numbered macro <N> where <N> is
  2919.                 an integer from 1 to 40
  2920.  
  2921. execute-named-command     M-X    Execute a command by name
  2922.  
  2923. execute-procedure     M-^E    Execute a procedure by name
  2924.  
  2925. execute-program     ^X$    Execute a program directly (not through
  2926.                 an intervening shell)
  2927.  
  2928. exit-emacs         ^X^C    Exit EMACS. If there are unwritten,
  2929.                 changed buffers EMACS will ask to confirm
  2930.  
  2931. fill-paragraph         M-Q    Fill the current paragraph
  2932.  
  2933. filter-buffer         ^X#    Filter the current buffer through an
  2934.                 external filter
  2935.  
  2936. find-file         ^X^F    Find a file to edit in the current window
  2937.  
  2938. forward-character     ^F    Move cursor one character to the right
  2939.  
  2940. goto-line         M-G    Goto a numbered line
  2941.  
  2942. goto-matching-fence     M-^F    Goto the matching fence
  2943.  
  2944. grow-window         ^X^    Make the current window larger
  2945.  
  2946. handle-tab         ^I    Insert a tab or set tab stops
  2947.  
  2948. hunt-forward         A-S    Hunt for the next match of the last
  2949.                 search string
  2950.  
  2951. hunt-backward         A-R    Hunt for the last match of the last
  2952.                 search string
  2953.  
  2954. help             M-?    Read EMACS.HLP into a buffer and display it
  2955.  
  2956. i-shell          ^XC    Shell up to a new command processor
  2957.  
  2958. incremental-search     ^XS    Search for a string, incrementally
  2959.  
  2960. insert-file         ^X^I    insert a file at the cursor in the
  2961.                 current file
  2962.  
  2963. insert-space         ^C    Insert a space to the right of the cursor
  2964.  
  2965. insert-string        (none)    Insert a string at the cursor
  2966.  
  2967. kill-paragraph         M-^W    Delete the current paragraph
  2968.  
  2969. kill-region         ^W    Delete the current marked region, moving
  2970.                 it to the kill buffer
  2971.  
  2972. kill-to-end-of-line     ^K    Delete the rest of the current line
  2973.  
  2974. list-buffers         ^X^B    List all existing buffers
  2975.  
  2976. meta-prefix         <ESC>    Key used to precede all META commands
  2977.  
  2978. mouse-move-down      MSa
  2979.  
  2980. mouse-move-up         MSb
  2981.  
  2982. mouse-resize-screen     MS1
  2983.  
  2984. mouse-region-down     MSe
  2985.  
  2986. mouse-region-up      MSf
  2987.  
  2988. move-window-down     ^X^N    Move all the lines in the current window down
  2989.  
  2990. move-window-up         ^X^P    Move all the lines in the current window up
  2991.  
  2992. name-buffer         M-^N    Change the name of the current buffer
  2993.  
  2994. narrow-to-region     ^X<    hides all text not in the current region
  2995.  
  2996. newline          ^M    Insert a <NL> at the cursor
  2997.  
  2998. newline-and-indent     ^J    Insert a <NL> at the cursor and indent
  2999.                 the new line the same as the preceding line
  3000.  
  3001. next-buffer         ^XX    Bring the next buffer in the list into
  3002.                 the current window
  3003.  
  3004. next-line         ^N    Move the cursor down one line
  3005.  
  3006. next-page         ^V    Move the cursor down one page
  3007.  
  3008. next-paragraph         M-N    Move cursor to the next paragraph
  3009.  
  3010. next-window         ^XO    Move cursor to the next window
  3011.  
  3012. next-word         M-F    Move cursor to the beginning of the
  3013.                 next word
  3014.  
  3015. nop            (none)    Does nothing
  3016.  
  3017. open-line         ^O    Open a line at the cursor
  3018.  
  3019. overwrite-string    (none)    Overwrite a string at the cursor
  3020.  
  3021. pipe-command         ^X@@    Execute an external command and place
  3022.                 its output in a buffer
  3023.  
  3024. previous-line         ^P    Move cursor up one line
  3025.  
  3026. previous-page         ^Z    Move cursor up one page
  3027.  
  3028. previous-paragraph     M-P    Move back one paragraph
  3029.  
  3030. previous-window      ^XP    Move the cursor to the last window
  3031.  
  3032. previous-word         M-B    Move the cursor to the beginning of the
  3033.                 word to the left of the cursor
  3034.  
  3035. print            (none)    Display a string on the command line
  3036.                 (a synonim to write-message)
  3037.  
  3038. query-replace-string     M-^R    Replace all of one string with another
  3039.                 string, interactively querying the user
  3040.  
  3041. quick-exit         M-Z    Exit EMACS, writing out all changed buffers
  3042.  
  3043. quote-character      ^Q    Insert the next character literally
  3044.  
  3045. read-file         ^X^R    Read a file into the current buffer
  3046.  
  3047. redraw-display         M-^L    Redraw the display, centering the
  3048.                 current line
  3049.  
  3050. resize-window         ^XW    Change the number of lines in the
  3051.                 current window
  3052.  
  3053. restore-window        (none)    Move cursor to the last saved window
  3054.  
  3055. replace-string         M-R    Replace all occurrences of one string
  3056.                 with another string from the cursor
  3057.                 to the end of the buffer
  3058.  
  3059. reverse-incremental-search^XR    Search backwards, incrementally
  3060.  
  3061. run             M-^E    Execute a named procedure
  3062.  
  3063. save-file         ^X^S    Save the current buffer if it is changed
  3064.  
  3065. save-window        (none)    Remember current window (to restore later)
  3066.  
  3067. scroll-next-up         M-^Z    Scroll the next window up
  3068.  
  3069. scroll-next-down     M-^V    Scroll the next window down
  3070.  
  3071. search-forward         ^S    Search for a string
  3072.  
  3073. search-reverse         ^R    Search backwards for a string
  3074.  
  3075. select-buffer         ^XB    Select a buffer to display in the
  3076.                 current window
  3077.  
  3078. set             ^XA    Set a variable to a value
  3079.  
  3080. set-encryption-key     M-E    Set the encryption key of the current buffer
  3081.  
  3082. set-fill-column      ^XF    Set the current fill column
  3083.  
  3084. set-mark            Set the mark
  3085.  
  3086. shell-command         ^X!    Causes an external shell to execute
  3087.                 a command
  3088.  
  3089. shrink-window         ^X^Z    Make the current window smaller
  3090.  
  3091. source            (none)    Execute a file as a macro
  3092.  
  3093. split-current-window     ^X2    Split the current window in two
  3094.  
  3095. store-macro        (none)    Store the following macro lines to a
  3096.                 numbered macro
  3097.  
  3098. store-procedure     (none)    Store the following macro lines to a
  3099.                 named procedure
  3100.  
  3101. transpose-characters     ^T    Transpose the character at the cursor
  3102.                 with the character to the left
  3103.  
  3104. trim-region         ^X^T    Trim any trailing white space from a region
  3105.  
  3106. unbind-key         M-^K    Unbind a key from a function
  3107.  
  3108. universal-argument     ^U    Execute the following command 4 times
  3109.  
  3110. unmark-buffer         M-~    Unmark the current buffer (so it is
  3111.                 no longer changed)
  3112.  
  3113. update-screen        (none)    Force a screen update during macro execution
  3114.  
  3115. view-file         ^X^V    Find a file,and put it in view mode
  3116.  
  3117. widen-from-region     ^X>    restores hidden text (see narrow-to-region)
  3118.  
  3119. wrap-word        (none)    Wrap the current word, this is an
  3120.                 internal function
  3121.         
  3122. write-file         ^X^W    Write the current buffer under a new
  3123.                 file name
  3124.  
  3125. write-message        (none)    Display a string on the command line
  3126.  
  3127. yank             ^Y    yank the kill buffer into the current
  3128.                 buffer at the cursor
  3129. @end(verbatim)
  3130. @appendix(MicroEMACS Bindings)
  3131.  
  3132.     Below is a complete list of the key bindings used in MicroEMACS.
  3133. This can be used as a wall chart reference for MicroEMACS commands.
  3134.  
  3135. @begin(verbatim)
  3136. @center(@b[Default Key Bindings for MicroEmacs 3.10])
  3137.  
  3138.  ^A   Move to start of line          ESC A   Apropos (list some commands)
  3139.  ^B   Move backward by characters     ESC B   Backup by words
  3140.  ^C   Insert space              ESC C   Initial capitalize word
  3141.  ^D   Forward delete              ESC D   Delete forward word
  3142.  ^E   Goto end of line              ESC E   Reset Encryption Key
  3143.  ^F   Move forward by characters      ESC F   Advance by words
  3144.  ^G   Abort out of things          ESC G   Go to a line
  3145.  ^H   Backward delete              
  3146.  ^I   Insert tab/Set tab stops
  3147.  ^J   Insert <NL>, then indent            
  3148.  ^K   Kill forward              ESC K   Bind Key to function
  3149.  ^L   Refresh the screen          ESC L   Lower case word
  3150.  ^M   Insert <NL>              ESC M   Add global mode
  3151.  ^N   Move forward by lines          ESC N   Goto End paragraph
  3152.  ^O   Open up a blank line          
  3153.  ^P   Move backward by lines          ESC P   Goto Begining of paragraph
  3154.  ^Q   Insert literal              ESC Q   Fill current paragraph
  3155.  ^R   Search backwards              ESC R   Search and replace
  3156.  ^S   Search forward              ESC S   Suspend (BSD only)
  3157.  ^T   Transpose characters               
  3158.  ^U   Repeat command four times       ESC U   Upper case word
  3159.  ^V   Move forward by pages          ESC V   Move backward by pages
  3160.  ^W   Kill region              ESC W   Copy region to kill buffer
  3161.  ^Y   Yank back from killbuffer       ESC X   Execute named command
  3162.  ^Z   Move backward by pages          ESC Z   Save all buffers and exit
  3163.  
  3164.  ESC ^C   Count words in region       ESC ~   Unmark current buffer
  3165.  ESC ^E   Execute named procedure
  3166.  ESC ^F   Goto matching fence          ESC !   Reposition window
  3167.  ESC ^H   Delete backward word          ESC <   Move to start of buffer
  3168.  ESC ^K   Unbind Key from function    ESC >   Move to end of buffer
  3169.  ESC ^L   Reposition window          ESC .   Set mark
  3170.  ESC ^M   Delete global mode          ESC space    Set mark
  3171.  ESC ^N   Rename current buffer       ESC rubout   Delete backward word
  3172.  ESC ^R   Search & replace w/query      rubout   Backward delete
  3173.  ESC ^S   Source command file
  3174.  ESC ^V   Scroll next window down
  3175.  ESC ^W   Delete Paragraph
  3176.  ESC ^X   Execute command line
  3177.  ESC ^Z   Scroll next window up
  3178.  
  3179.  ^X <    Narrow-to-region       ^X ?   Describe a key
  3180.  ^X >    Widen-from-region       ^X !   Run 1 command in a shell
  3181.  ^X =    Show the cursor position   ^X @@   Pipe shell command to buffer
  3182.  ^X ^    Enlarge display window       ^X #   Filter buffer thru shell filter
  3183.  ^X 0    Delete current window       ^X $   Execute an external program
  3184.  ^X 1    Delete other windows       ^X (   Begin macro
  3185.  ^X 2    Split current window       ^X )   End macro
  3186.                    ^X A   Set variable value
  3187.  ^X ^B     Display buffer list       ^X B   Switch a window to a buffer
  3188.  ^X ^C     Exit MicroEMACS       ^X C   Start a new command processor
  3189.  ^X ^D     Detab line           ^X D   Suspend MicroEMACS (BSD4.2 only)
  3190.  ^X ^E     Entab line           ^X E   Execute macro
  3191.  ^X ^F     Find file           ^X F   Set fill column
  3192.  ^X ^I     Insert file
  3193.                    ^X K   Delete buffer
  3194.  ^X ^L     Lower case region
  3195.  ^X ^M     Delete Mode           ^X M   Add a mode
  3196.  ^X ^N     Move window down       ^X N   Rename current filename
  3197.  ^X ^O     Delete blank lines       ^X O   Move to the next window
  3198.  ^X ^P     Move window up        ^X P   Move to the previous window
  3199.  ^X ^R     Get a file from disk       ^X R   Incremental reverse search
  3200.  ^X ^S     Save current file       ^X S   Incremental forward search
  3201.  ^X ^T     Trim line           (Incremental search
  3202.  ^X ^U     Upper case region          not always available)
  3203.  ^X ^V     View file
  3204.  ^X ^W     Write a file to disk       ^X W   resize Window
  3205.  ^X ^X     Swap "." and mark       ^X X   Use next buffer
  3206.  ^X ^Z     Shrink window           ^X Z   Enlarge display window
  3207.  
  3208. @u(Usable Modes)
  3209. WRAP     Lines going past right margin "wrap" to a new line
  3210. VIEW     Read-Only mode where no modifications are allowed
  3211. CMODE     Change behavior of some commands to work better with C
  3212. EXACT     Exact case matching on search strings
  3213. OVER     Overwrite typed characters instead of inserting them
  3214. CRYPT     Current buffer will be encrypted on write, decrypted on read
  3215. MAGIC     Use regular expression matching in searches
  3216. ASAVE     Save the file every 256 inserted characters
  3217.  
  3218. WHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK    Sets foreground color
  3219. white/cyan/magenta/yellow/blue/red/green/black    Sets background color
  3220. @end(verbatim)
  3221. @newpage
  3222. @appendix(Supported machines)
  3223.  
  3224.     The following table lists all the hardware/compilers for which I
  3225. currently support MicroEMACS.  This is not exclusive of all machines
  3226. which MicroEMACS will run on, but I have either run it myself, or had a
  3227. first hand report of it running.
  3228.  
  3229. @begin(verbatim)
  3230. @u(Hardware    OS        Compiler    Comments)
  3231. VAX 780     UNIX V5     native
  3232.         UNIX V7     native
  3233.         BSD 4.2     native        job control supported
  3234.         *VMS        native
  3235.  
  3236. NCR Tower    UNIX V5     native
  3237.  
  3238. IBM-RT PC    BSD 4.3     native
  3239.  
  3240. HP9000        UNIX V5     native
  3241.  
  3242. Fortune 32:16    UNIX V7     native
  3243.  
  3244. IBM-PC        MSDOS        LATTICE 2.15    Large CODE/Large DATA
  3245.          2.0 & 3.2    AZTEC 3.4e    Large CODE/Large DATA
  3246.                 TURBO C v1.5    LARGE memory model
  3247.                 MSC 4.0
  3248.                 *MWC 86
  3249.         SCO XENIX    native
  3250.  
  3251. HP150        MSDOS        Lattice 2.15    Function key labels
  3252.                         for the touch screen
  3253.  
  3254. HP110        MSDOS        Lattice 2.15
  3255.                 Aztec 3.4e
  3256.  
  3257. *Data General 10
  3258.         MSDOS        Lattice 2.1  Texas Instruments Professional
  3259.         MSDOS        Lattice 2.15
  3260.  
  3261. Amiga        Intuition    Lattice 3.03
  3262.                 Aztec 3.6
  3263.  
  3264. ST520        TOS        Mark Williams C Spawns under MSH
  3265.                 Lattice 3.10    (no shell commands)
  3266.  
  3267. @u[Systems to be supported (IE some code is already written:)]
  3268. Macintosh    Finder 5.0    Aztec
  3269.  
  3270. *means that I do not own or have access to the listed compiler and/or
  3271.  machine and must rely upon others to help support it. 
  3272. @end(verbatim)
  3273. @newpage
  3274. @appendix(Function Keys)
  3275.  
  3276.     On the IBMPC, the ATARI ST, the Commodore AMIGA and UNIX now
  3277. support a set of machine independant bindings for function keys.  Below
  3278. is a list of these bindings (not all of these are supported on all
  3279. systems).
  3280.  
  3281. @begin(verbatim)
  3282.             Function keys in MicroEmacs
  3283.  
  3284.     function    Function    ^function    Alt-function
  3285.  f1)      FN1         S-FN1          FN^1          A-FN1
  3286.  f2)      FN2         S-FN2          FN^2          A-FN2
  3287.  f3)      FN3         S-FN3          FN^3          A-FN3
  3288.  f4)      FN4         S-FN4          FN^4          A-FN4
  3289.  f5)      FN5         S-FN5          FN^5          A-FN5
  3290.  f6)      FN6         S-FN6          FN^6          A-FN6
  3291.  f7)      FN7         S-FN7          FN^7          A-FN7
  3292.  f8)      FN8         S-FN8          FN^8          A-FN8
  3293.  f9)      FN9         S-FN9          FN^9          A-FN9
  3294. f10)      FN0         S-FN0          FN^0          A-FN0
  3295.  
  3296. home)      FN<                  FN^<
  3297. CsUp)      FNP                  FN^P
  3298. PgUp)      FNZ                  FN^Z
  3299. CsLf)      FNB                  FN^B
  3300.  5  )
  3301. CsRt)      FNF                  FN^F
  3302.  End)      FN>                  FN^>
  3303. CsDn)      FNN                  FN^N
  3304. PgDn)      FNV                  FN^V
  3305.  Ins)      FNC                  FN^C
  3306.  Del)      FND                  FN^D
  3307. @end(verbatim)
  3308. @newpage
  3309. @appendix(Machine Dependent Notes)
  3310.  
  3311.     This appendix lists some notes specific to individual
  3312. implementations of MicroEMACS.    Every attempt has been made to allow
  3313. EMACS to be identical on all machines, but we have also tried to take
  3314. advantage of function keys, cursor keys, mice, and special screen modes
  3315. where possible.
  3316.  
  3317. @appendixsection(IBM-PC/XT/AT and its clones)
  3318.  
  3319.     The IBM-PC family of computers is supported with a variety of
  3320. different display adapters.  EMACS will attempt to discover what adapter
  3321. is connected and use the proper driver for it.    Below is a list of the
  3322. currently supported video adapters:
  3323.  
  3324. @begin(verbatim)
  3325. @u(Adapter            $sres        Original mode used)
  3326. Monochrome Graphics Adapter    MONO        MONO
  3327. Color Graphics Adapter        CGA        CGA
  3328. Enhanced Graphics Adapter    EGA        CGA
  3329. Video Graphics Adapter        VGA        CGA
  3330. @end(verbatim)
  3331.  
  3332.     If a driver for a Microsoft compatable mouse is installed on the
  3333. system, EMACS will use the mouse in text mode and allow the user all the
  3334. standard mouse functions.  The mouse cursor will appear to be a block of
  3335. color in the color opposite of it's background.
  3336.  
  3337.     EMACS also takes advantage of various function keys and the keys
  3338. on the keypad on an IBM-PC.  The function keys are initially not bound
  3339. to any particular functions (except by the emacs.rc startup file), but
  3340. the keypad keys do default to the following:
  3341.  
  3342. @begin(verbatim)
  3343. @u(Keypad key    Function)
  3344. Home        beginning-of-file
  3345. CSRS UP     previous-line
  3346. Pg Up        previous-page
  3347. CSRS LEFT    backward-character
  3348. CSRS RIGHT    forward-character
  3349. End        end-of-file
  3350. CSRS DOWN    next-line
  3351. Pg Dn        Next-page
  3352. @end(verbatim)
  3353.  
  3354.     All these special keys are indicated in EMACS macroes by use of
  3355. the @b(FN) prefix.  Below is a list of many of the keys and the codes
  3356. used to specify them.  Also the codes may be gotten by using the
  3357. describe-key (^X ?) command on the suspect key.
  3358.  
  3359. @flushleft(@b[Compiling under TURBO C])
  3360.  
  3361.     To compile MicroEMACS under TURBO C, set the TURBO integrated
  3362. environment with the following options:
  3363.  
  3364.     Memory model        LARGE
  3365.     Floating point        NONE
  3366.     Default char type    UNSIGNED
  3367.     Data alignment        BYTE
  3368.     Merge duplicate strings ON
  3369.     Standard stack frame    off
  3370.     Test stack overflow    off
  3371.  
  3372.     Optimize for            SIZE
  3373.     Use register optimization    ON
  3374.     Register optimization        ON
  3375.     Jump optimization        ON
  3376.  
  3377.     Initialize segments    OFF
  3378.     Stack warnings        OFF
  3379.  
  3380.     Names: Code names
  3381.         Segment name    *
  3382. @newpage
  3383. @appendixsection(HP 150)
  3384.  
  3385.     This machine from Hewlett Packard is very unusual for an MSDOS
  3386. machine.  It has a touch screen and is very function key oriented.  An
  3387. additional command, @i(label-function-key)@index(label-function-key)
  3388. allows you to place labels on the on screen function key labels.  A
  3389. numeric argument indicates which function key to label (one through
  3390. eight) and then the program prompts for a 16 character label, which will
  3391. be used as two lines of eight characters.  To label function key three
  3392. with "save file" from a macro, you would use:
  3393.  
  3394. @verbatim(3 label-function-key "save    file")
  3395.  
  3396.     Notice the 4 spaces after "save".  This forces "file" to begin on
  3397. the second line of the label.
  3398. @newpage
  3399. @appendixsection(Atari 520/1040ST)
  3400.  
  3401.     The ATARI ST family of computers have a dual personality.  They
  3402. may use either a monochrome or a color screen.    EMACS supports two
  3403. screen resolutions on each monitor. 
  3404.  
  3405. @center(@b[NOTE])
  3406.  
  3407. @quotation(When you set MicroEMACS up on your system, please remember to
  3408. install it on the desktop as a GEM application.  If you have EMACS set
  3409. as a TOS application, the mouse will not function properly, and EMACS
  3410. will alert you to this problem by beeping the bell.)
  3411.  
  3412. @begin(verbatim)
  3413. @u(Monitor $sres size #color $palette format)
  3414. Color    LOW    40x25    16    000111222333444555666777
  3415.     MEDIUM    80x25    4    000111222333
  3416. Mono    HIGH    80x25    2    000
  3417.     DENSE    80x50    2    000
  3418. @end(verbatim)
  3419.  
  3420.     The $palette environment variable can be used to change what
  3421. color is associated with each color name.  With a color monitor, each
  3422. group of three digits indicates an octal number specifying the RED,
  3423. GREEN and BLUE levels of that color.  Each color digit can vary from 0
  3424. to 7.  For example, the initial setting of $palette in LOW resolution is:
  3425.  
  3426. @begin(verbatim)
  3427.     000700070770007707077777
  3428.  
  3429.     which broken up is:
  3430.  
  3431.     000 700 070 770 007 707 077 777
  3432.  
  3433.     which means:
  3434.  
  3435.     000    Black
  3436.     700    Red
  3437.     070    Green
  3438.     770    Yellow
  3439.     007    Blue
  3440.     707    Magenta
  3441.     077    Cyan
  3442.     777    White
  3443. @end(verbatim)
  3444.  
  3445.     Also the mouse buttons are bound to mouse functions as
  3446. described in the chapter about mice. The cursor keys and the function
  3447. keys are bound similarly to IBM-PC.
  3448.  
  3449.     Files generated by EMACS on the ATARI ST have a single return
  3450. character at the end of each line, unlike the desktop files which want
  3451. to have two returns. This makes it display files strangely from GEM's
  3452. [SHOW] option, but makes the files port to other computers much nicer.
  3453. When compiling MicroEMACS, the ADDCR symbol in @b(estruct.h) will cause
  3454. emacs to generate line ending sequences compatible with GEM.
  3455.  
  3456.     Currently, when operating under the Mark Williams MSH program,
  3457. EMACS can shell out and perform external commands. This capability will
  3458. be added later for the Beckmeyer shell and under GEMDOS.
  3459. @newpage
  3460. @appendixsection(Amiga 1000)
  3461.  
  3462.     The Commodore AMIGA 1000 version of MicroEMACS does fully
  3463. support the mouse, window resizing and the close gadget.  It runs in
  3464. medium resolution, using the colors defined for the workbench.  
  3465.  
  3466. @center(Note about Compiling MicroEMACS)
  3467.  
  3468. @begin(quotation)
  3469.     If you are compiling the sources on the AMIGA to produce an
  3470. executable image, and you are using the Lattice compiler, be sure to
  3471. give the CLI command 'STACK 40000' before compiling to make sure the
  3472. compiler has sufficient stack space to successfully complete
  3473. compilation.
  3474. @end(quotation)
  3475. @newpage
  3476. @appendixsection(UNIX V5, V7, and BSD4.[23])
  3477.  
  3478.     MicroEMACS under UNIX utilizes the @b(TERMCAP) @index(termcap)
  3479. library to provide machine independent screen functions.  Make sure that
  3480. termcap is available and properly set on your account before attempting
  3481. to use MicroEMACS. 
  3482.  
  3483.     Under systems which support job control, you can use the
  3484. @b(^XD) @i(suspend-emacs) @index(suspend-emacs) command to place EMACS
  3485. into the background.  This carries a much smaller overhead than bringing
  3486. up a new shell under EMACS.  EMACS will properly redraw the screen when
  3487. you bring it back to the foreground.
  3488.  
  3489.     If the symbol VT100 has been set to 1 in the @i(estruct.h)
  3490. options file, EMACS will recognize the key sequence <ESC>[ as the lead
  3491. in sequence for the FN function key prefix.
  3492.  
  3493.     With the addition of some very machine/operating system specific
  3494. code, EMACS can prevent two or more people from modifying the same file
  3495. at the same time.  @index(file locking) The upper level of a set of
  3496. functions to provide file locking exist in the source file @b(LOCK.C). 
  3497. It requires two machine specific functions written and linked into EMACS
  3498. for it to operate properly. 
  3499.  
  3500. @begin(verbatim)
  3501.     char *dolock(fname)
  3502.  
  3503.     char *fname;
  3504.  
  3505.     dolock() locks a file, preventing others from modifying it. If
  3506.     it succeeds, it returns NULL, otherwise it returns a pointer to
  3507.     a string in the form "LOCK ERROR: explanation".
  3508.  
  3509.     char *undolock(fname)
  3510.  
  3511.     char *fname;
  3512.  
  3513.     undolock() unlocks a file, allowing others to modifying it. If
  3514.     it succeeds, it returns NULL, otherwise it returns a pointer to
  3515.     a string in the form "LOCK ERROR: explanation".
  3516. @end(verbatim)
  3517. @newpage
  3518. @appendixsection(DEC VMS operating system)
  3519.  
  3520. @flushleft(@b[TERMINALS])
  3521.  
  3522.     MicroEMACS uses the capabilities of VMS SMG, and should work
  3523. with any terminal that is defined in SMGTERMS.TXT or TERMTABLE.TXT. 
  3524. (See your SMG manual for more information.) Full keyboard support, with
  3525. function keys and everything, is provided for VT100 and VT200 series
  3526. compatible terminals.  Mouse support is provided for the VSII
  3527. workstation's VT220 terminal emulator, and other terminal emulators
  3528. that use the same escape sequences for mouse control.  (There is some
  3529. partial support for the BBN BitGraph mouse sequences in the sources,
  3530. but this is not yet complete.) Terminals may have up to 100 lines and
  3531. 160 columns. 
  3532.  
  3533. @flushleft(@b[KEYBOARD])
  3534.  
  3535.     The VMS version understands the LK201 functions of VT200
  3536. series, vt300 series, and compatible terminals and terminal emulators,
  3537. and allows you to bind to them as function keys.  In addition, the
  3538. VT100 numeric keypad, in application mode, is available as function
  3539. keys.  MicroEMACS does not, however, put the keypad into application
  3540. mode for you.  This is done by issuing the command "SET TERM
  3541. /APPLICATION" before entering MicroEMACS. 
  3542.  
  3543. @begin(verbatim)
  3544. @u(VT200 keys)
  3545.  
  3546. F6   = FN^Q    F7     = FN^R    F8     = FN^S    F9     = FN^T    F10  = FN^U
  3547. F11  = FN^W    F12    = FN^X    F13    = FN^Y    F14    = FN^Z    HELP = FN^\
  3548. DO   = FN^]    F17    = FN^_    F18    = "FN "    F19    = FN!    F20  = FN"
  3549. FIND = FN^A    INSERT = FN^B    REMOVE = FN^C    SELECT = FN^D    PREV = FN^E
  3550. NEXT = FN^F
  3551.  
  3552. @u(VT100 and VT200 Arrow keys)
  3553.  
  3554. Up = FNA    Down = FNB    Right = FNC    Left = FND
  3555.  
  3556. @u(VT100 and VT200 numeric keypad in SET TERM /APPLICATION mode)
  3557.  
  3558. PF1 = FNP9    PF2 = FNQ    PF3 = FNR    PF4   = FNS
  3559. 7   = FNw    8   = FMx    9   = FNy    -     = FNm
  3560. 4   = FNt    5   = FNu    6   = FNv    ,     = FNl
  3561. 1   = FNq    2   = FNr    3   = FNs    ENTER = FNM
  3562. 0   = FNp    .   = FNn
  3563. @end(verbatim)
  3564.  
  3565. @center(@b[WARNING])
  3566.  
  3567. @begin(quotation)
  3568.     The VMS version contains code for interpreting function keys
  3569. that are sent as Ansi sequences that begin with the ESC character. 
  3570. Because of this, MicroEMACS cannot process an incoming ESC until it
  3571. knows what character follows it.  This can cause problems with
  3572. terminating search and replace strings. If you use ESC as the
  3573. meta-prefix character (which is the default) you must type one
  3574. additional keystroke following ESC before emacs will recognize that you
  3575. have edited the search command prompt, and are continuing.  (The
  3576. additional character is processed normally be MicroEMACS, it is NOT
  3577. discarded.)
  3578. @end(quotation)
  3579.  
  3580. @flushleft(@b[Flow control])
  3581.  
  3582.     Some terminals will require the use of XON/XOFF flow control
  3583. when used with MicroEMACS.  When XON/XOFF flow control is used, you
  3584. will not be able to use functions bound to ^S or ^Q, and should use
  3585. bind-to-key to put these functions on other keys.  MicroEMACS does not
  3586. change the flow control characteristics of your terminal line while it
  3587. is running.  If your terminal requires flow control, you should:
  3588.  
  3589.     $ SET TERM/HOSTSYNC/TTSYNC
  3590.  
  3591.     before entering MicroEMACS.  If you are on a VSII emulated
  3592. workstation terminal, are using the SSU multi-session protocol (VT330
  3593. and VT340 with SSU enabled), or are certain that your terminal does not
  3594. require XON/XOFF flow control, you should
  3595.  
  3596.     $ SET TERM /HOSTSYNC/NOTTSYNC
  3597.  
  3598.     This will allow you to use ^S and ^Q for MicroEMACS commands.
  3599. Note that if you are using a VSII with VWS V3.2 or later, you must
  3600. leave the /HOSTSYNC enabled in order for the cross/session cut and
  3601. paste capability to work properly.
  3602.  
  3603.  
  3604. @flushleft(@b[Search List for EMACS.RC])
  3605.  
  3606.     VMS MicroEMACS will first search logical name MICROEMACS$LIB:,
  3607. and then "sys$sysdevice:[vmstools]" when looking for startup files or
  3608. help files.
  3609.  
  3610.     Please use MICROEMACS$LIB:, and allow the secondary search of
  3611. [vmstools] to become archaic.  If desired, MICROEMACS$LIB may be
  3612. defined to be a VMS search list that first searches a user directory,
  3613. and then a system directory. 
  3614.  
  3615.     Generally, you should create a private directory where you keep
  3616. all your .CMD files, and in your LOGIN.COM $DEFINE a logical name to
  3617. point to this area.
  3618.  
  3619. @flushleft(@b[Using MicroEMACS with VMS MAIL and NOTES])
  3620.  
  3621.     There are two ways of using MicroEMACS with MAIL and NOTES. 
  3622. The first way requires the cooperation of your system manager, but is
  3623. faster and less taxing on system resources.  The second way can be done
  3624. by any random user that has PRCLM quota that is greater than 1, but it
  3625. creates a new subprocess each time MicroEMACS is called up from the
  3626. application, and is therefore slower to invoke and more demanding on
  3627. system resources.  Obviously, the first way is recommended.
  3628.  
  3629. @begin(verbatim)
  3630. @u(First way)
  3631.  
  3632. 1. $ SET PROC/PRIV=ALL
  3633. 2. $ Copy MESHR.EXE SYS$SHARE:MESHR.EXE/PROT=WO:RE
  3634. 3. $ INSTALL :== $INSTALL
  3635. 4. $ INSTALL/COMMAND ADD SYS$SHARE:MESHR.EXE
  3636. @end(verbatim)
  3637.  
  3638.     Step 4, and possibly step 3, must be incorporated into the
  3639. system-wide startup command file, usually SYS$MANAGER:SYSTARTUP.COM, so
  3640. that MicroEMACS will be installed each time the system boots.  Note
  3641. that the filename MUST be "MESHR.EXE".
  3642.  
  3643. @flushleft(5. $ DEFINE MAIL$EDIT CALLABLE_ME)
  3644.  
  3645.     Step 5 must be added to the LOGIN.COM of each user that wishes
  3646. to have MicroEMACS as their MAIL editor.  Additionally, they may wish
  3647. to have the line $ ME :== $SYS$SHARE:MESHR.EXE, which will allow them
  3648. to use the "ME" command for invoking MicroEMACS from DCL.
  3649.  
  3650. @flushleft(6. $ NOTES)
  3651. @flushleft[   NOTES> SET PROFILE/EDIT=(ME,CALL)]
  3652.  
  3653.     Step 6 must be performed by each user that wishes to have
  3654. MicroEMACS as their NOTES editor.
  3655.  
  3656. NOTE: If you already have a version of MicroEMACS installed, and you
  3657. wish to install a new version in a running system, you must
  3658. REMOVE the old image and INSTALL the new one before MAIL or NOTES will
  3659. recognize it.  To perform the upgrade, use following sequence of commands:
  3660.  
  3661. @begin(verbatim)
  3662. $ install :== $install
  3663. $ set proc /priv=all
  3664. $ install/command remove sys$share:meshr.exe
  3665. $ copy meshr.exe sys$share:/log/prot=wo:re
  3666. $ install/command add sys$share:meshr.exe
  3667. @end(verbatim)
  3668.  
  3669. @flushleft(@b[Second way])
  3670.  
  3671.     In the event that you cannot get your system manager to INSTALL
  3672. MicroEMACS as known image, you can use the following technique:
  3673.  
  3674. @begin(verbatim)
  3675. 1. In MICROEMACS$LIB:MEMAIL.COM, put the following command file:
  3676.  
  3677. $! Use on VAX/VMS as MAIL$EDIT for using MicroEMACS as mail editor.
  3678. $ if "''P1'" .NES. "_NL:" then if "''P1'" .NES. "" then copy 'P1' 'P2'
  3679. $ define/user sys$input sys$output
  3680. $ me 'P2'
  3681. $ exit
  3682.  
  3683. This file may have come with your MicroEMACS kit.
  3684.  
  3685. 2. In your LOGIN.COM, put the following lines:
  3686.  
  3687. $    me :== $MICROEMACS$LIB:MESHR.EXE ! Assumes meshr.exe is there
  3688. $    define mail$edit microemacs$lib:me_edit.com
  3689.  
  3690. 3. In NOTES, give the command
  3691.  
  3692. NOTES> SET PROFILE/EDIT=(@@MicroEMACS$lib:me_edit.com,SPAWN)
  3693.  
  3694. @flushleft(@b[Building MicroEMACS for VMS])
  3695.  
  3696. The configuration options are set in file estruct.h:
  3697.  
  3698. - Under the category of "Machine/OS definitions", set VMS to "1" and all
  3699. others to "0". 
  3700.  
  3701. - Under "Compiler definitions", set all selections to "0".  Selecting
  3702. VMS implies that you are using VAXC.
  3703.  
  3704. - Under "Special keyboard definitions", be sure "VT100" is set to "0". 
  3705. This option is not required for the VMS version, it is for versions
  3706. linked with ANSI terminal support.  VMSVT already handles the special
  3707. characteristics of Ansi keyboards.
  3708.  
  3709. - Under "Terminal Output definitions", set VMSVT to "1" and all others
  3710. to "0". 
  3711.  
  3712. - Under "Configuration options", you may select as you wish, with the
  3713. following notes:
  3714.  
  3715.     - COLOR    support does not exist for VMS, even when using
  3716.         color workstations.
  3717.     - MOUSE    support should be enabled if you have any VSII workstations
  3718. @end(verbatim)
  3719.  
  3720.     If you have MMS, you can use the supplied DESCRIP.MMS to build
  3721. MicroEMACS.  If you do not have MMS, simply compile each module with
  3722. "CC", and link with the command:
  3723.  
  3724.     $ LINK MESHR/OPTION/SHARE
  3725.  
  3726.     Note that the executable filename must end in "SHR" in order
  3727. for MicroEMACS to be used as a callable editor from MAIL or NOTES. 
  3728. (Method 1 above.)
  3729.  
  3730.     If you edit any of the Emacs sources, note that any global or
  3731. external data must be declared as "noshare" in order for the VMS
  3732. callable editor support to work properly.  This applies to all global
  3733. data used in the VMS version, but not to routines or to "static "data. 
  3734. The "noshare" declaration is #define'd away on non-VMS systems.  If you
  3735. fail to do this, VMS will not allow you to INSTALL MicroEMACS as a
  3736. sharable library.
  3737. @newpage
  3738. @appendix(Mode Flags)
  3739.  
  3740.     The two environment variables, $cmode and $gmode, contain a
  3741. number the corresponds to the modes set for the current buffer and
  3742. the editor as a whole.    These are encoded as the sum of the following
  3743. numbers for each of the possible modes:
  3744.  
  3745. @begin(verbatim)
  3746. WRAP      1        Word wrap
  3747. CMODE      2        C indentation and fence match
  3748. SPELL      4        Interactive spell checking (Not Implemented Yet)
  3749. EXACT      8        Exact matching for searches
  3750. VIEW     16        Read-only buffer
  3751. OVER     32        Overwrite mode
  3752. MAGIC     64        Regular expressions in search
  3753. CRYPT    128        Encryption mode active
  3754. ASAVE    256        Auto-save mode
  3755. @end(verbatim)
  3756.  
  3757.     So, if you wished to set the current buffer to have CMODE,
  3758. EXACT, and MAGIC on, and all the others off, you would add up the values
  3759. for those three, CMODE 2  +  EXACT 8  +  MAGIC 64 = 74, and use a
  3760. statement like:
  3761.  
  3762. set $cmode 74
  3763.  
  3764.     or, use the binary or operator to combine the different modes:
  3765.  
  3766. set $cmode &bor &bor 2 8 64
  3767.  
  3768. @flushleft(@big[Internal Flags])
  3769.  
  3770.     Some of the ways EMACS controls its internal functions can be
  3771. modified by the value in the $gflags@index($gflags) environment
  3772. variable.  Each bit in this variable will be used to control a
  3773. different function.
  3774.  
  3775. @begin(verbatim)
  3776. GFFLAG        1    If this bit is set to zero, EMACS will not
  3777.             automatically switch to the buffer of the
  3778.             first file after executing the startup macros.
  3779. @end(verbatim)
  3780.  
  3781. @flushleft(@big[Current buffer flags])
  3782.  
  3783.     The $cbflags@index($cbflags) environment variable allows the
  3784. user to modify some of the characteristics of the current buffer.  The
  3785. various characteristics are encoded as the sum of the following
  3786. numbers:
  3787.  
  3788. @begin(verbatim)
  3789. BFINVS        1    Internal invisible buffer
  3790. BFCHG        2    Changed since last write
  3791. BFTRUNC     4    buffer was truncated when read
  3792. BFNAROW     8    buffer has been narrowed
  3793. @end(verbatim)
  3794.  
  3795.     Only the invisible and changed flags can be modified by setting
  3796. the $cbflags variable.    The truncated file and narrowed flags are read
  3797. only.
  3798.